|
1 | 1 | import { Uri, workspace, window, TextDocument } from 'vscode'; |
2 | 2 |
|
3 | 3 | import { Config } from './configration'; |
4 | | -import { execSync } from 'child_process'; |
| 4 | +import { exec } from 'child_process'; |
5 | 5 | import { AssemblerDiag } from './language/diagnose'; |
6 | 6 | import * as nls from 'vscode-nls'; |
7 | 7 | const localize = nls.loadMessageBundle(); |
@@ -30,25 +30,28 @@ export class DOSBox { |
30 | 30 | //command for open dosbox |
31 | 31 | let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" '; |
32 | 32 | //exec command by terminal |
| 33 | + let callback = (error: any) => { |
| 34 | + if (error) { console.error(error); }; |
| 35 | + if (diag && doc) { this.BOXdiag(conf, diag, doc); } |
| 36 | + }; |
33 | 37 | if (process.platform === 'win32') { |
34 | 38 | if (doc) { command = 'del/Q T*.* & copy "' + doc.fileName + '" "T.ASM" & ' + command; } |
35 | | - execSync(command + boxcommand, { cwd: conf.workpath, shell: 'cmd.exe' }); |
| 39 | + exec(command + boxcommand, { cwd: conf.workpath, shell: 'cmd.exe' }, callback); |
36 | 40 | } |
37 | 41 | else { |
38 | 42 | if (doc) { command = 'rm -f [Tt]*.*;cp "' + doc.fileName + '" T.ASM;' + command; } |
39 | | - execSync(command + boxcommand, { cwd: conf.workpath }); |
| 43 | + exec(command + boxcommand, { cwd: conf.workpath }, callback); |
40 | 44 | } |
41 | | - if (diag && doc) { this.BOXdiag(conf, diag, doc); } |
42 | 45 | } |
43 | 46 | public BoxOpenCurrentFolder(conf: Config, doc: TextDocument) { |
44 | 47 | let folderpath: string = Uri.joinPath(doc.uri, '../').fsPath; |
45 | 48 | let Ecmd: string = '-noautoexec -c "mount e \\\"' + folderpath + '\\\"" -c "mount c \\\"' + conf.path + '\\\"" -c "set PATH=%%PATH%%;c:\\masm;c:\\tasm" -c "e:"'; |
46 | 49 | let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" '; |
47 | 50 | if (process.platform === 'win32') { |
48 | | - execSync(command + Ecmd, { cwd: conf.workpath, shell: 'cmd.exe' }); |
| 51 | + exec(command + Ecmd, { cwd: conf.workpath, shell: 'cmd.exe' }); |
49 | 52 | } |
50 | 53 | else { |
51 | | - execSync(command + Ecmd, { cwd: conf.workpath }); |
| 54 | + exec(command + Ecmd, { cwd: conf.workpath }); |
52 | 55 | } |
53 | 56 |
|
54 | 57 | } |
|
0 commit comments