Skip to content

Commit b2101c9

Browse files
committed
Fix the offending code by typescriptlint
1 parent e35f7ac commit b2101c9

File tree

10 files changed

+589
-588
lines changed

10 files changed

+589
-588
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"out": true // set this to false to include "out" folder in search results
88
},
99
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10-
"typescript.tsc.autoDetect": "off"
10+
"typescript.tsc.autoDetect": "off",
11+
"editor.formatOnSave": true
1112
}

src/DOSBox.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Uri, workspace, window, TextDocument } from 'vscode'
1+
import { Uri, workspace, window, TextDocument } from 'vscode';
22

3-
import { Config } from './configration'
4-
import { execSync } from 'child_process'
5-
import { landiagnose } from './language/diagnose'
3+
import { Config } from './configration';
4+
import { execSync } from 'child_process';
5+
import { AssemblerDiag } from './language/diagnose';
66
import * as nls from 'vscode-nls';
7-
const localize = nls.loadMessageBundle()
7+
const localize = nls.loadMessageBundle();
88
export class DOSBox {
99
constructor() {
1010
}
@@ -14,53 +14,53 @@ export class DOSBox {
1414
* @param doc 需要处理的文件,假如有会清理工作文件夹,复制该文件到工作文件夹
1515
* @param diag 如果有则诊断输出信息
1616
*/
17-
public openDOSBox(conf: Config, more?: string, doc?: TextDocument, diag?: landiagnose) {
18-
let boxcommand = ' '
17+
public openDOSBox(conf: Config, more?: string, doc?: TextDocument, diag?: AssemblerDiag) {
18+
let boxcommand = ' ';
1919
if (more) {
20-
let boxparam = more.replace(/\n/g, '"-c "')
21-
boxcommand = '-c "' + boxparam + '"'
20+
let boxparam = more.replace(/\n/g, '"-c "');
21+
boxcommand = '-c "' + boxparam + '"';
2222
}
23-
let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" '
24-
if (process.platform == 'win32') {
25-
if (doc) command = 'del/Q T*.* & copy "' + doc.fileName + '" "T.ASM" & ' + command
26-
execSync(command + boxcommand, { cwd: conf.workpath, shell: 'cmd.exe' })
23+
let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" ';
24+
if (process.platform === 'win32') {
25+
if (doc) { command = 'del/Q T*.* & copy "' + doc.fileName + '" "T.ASM" & ' + command; }
26+
execSync(command + boxcommand, { cwd: conf.workpath, shell: 'cmd.exe' });
2727
}
2828
else {
29-
if (doc) command = 'rm -f [Tt]*.*;cp "' + doc.fileName + '" T.ASM;' + command
30-
execSync(command + boxcommand, { cwd: conf.workpath })
29+
if (doc) { command = 'rm -f [Tt]*.*;cp "' + doc.fileName + '" T.ASM;' + command; }
30+
execSync(command + boxcommand, { cwd: conf.workpath });
3131

3232
}
33-
if (diag && doc) this.BOXdiag(conf, diag, doc)
33+
if (diag && doc) { this.BOXdiag(conf, diag, doc); }
3434
}
3535
public BoxOpenCurrentFolder(conf: Config, doc: TextDocument) {
36-
let folderpath: string = Uri.joinPath(doc.uri, '../').fsPath
37-
let Ecmd: string = '-noautoexec -c "mount e \\\"' + folderpath + '\\\"" -c "mount c \\\"' + conf.path + '\\\"" -c "set PATH=%%PATH%%;c:\masm;c:\\tasm"-c "e:"'
38-
let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" '
39-
if (process.platform == 'win32') {
40-
execSync(command + Ecmd, { cwd: conf.workpath, shell: 'cmd.exe' })
36+
let folderpath: string = Uri.joinPath(doc.uri, '../').fsPath;
37+
let Ecmd: string = '-noautoexec -c "mount e \\\"' + folderpath + '\\\"" -c "mount c \\\"' + conf.path + '\\\"" -c "set PATH=%%PATH%%;c:\masm;c:\\tasm"-c "e:"';
38+
let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" ';
39+
if (process.platform === 'win32') {
40+
execSync(command + Ecmd, { cwd: conf.workpath, shell: 'cmd.exe' });
4141
}
4242
else {
43-
execSync(command + Ecmd, { cwd: conf.workpath })
43+
execSync(command + Ecmd, { cwd: conf.workpath });
4444
}
4545

4646
}
47-
private BOXdiag(conf: Config, diag: landiagnose, doc: TextDocument): string {
48-
let info: string = ' ', content: string
49-
let document = doc
47+
private BOXdiag(conf: Config, diag: AssemblerDiag, doc: TextDocument): string {
48+
let info: string = ' ', content: string;
49+
let document = doc;
5050
if (document) {
51-
content = document.getText()
51+
content = document.getText();
5252
workspace.fs.readFile(conf.workloguri).then(
5353
(text) => {
54-
info = text.toString()
55-
if (diag.ErrMsgProcess(content, info, doc.uri, conf.MASMorTASM) == 0) {
56-
let Errmsgwindow = localize("dosbox.errmsg", '{0} Failed to compile. See the output for more information', conf.MASMorTASM)
54+
info = text.toString();
55+
if (diag.ErrMsgProcess(content, info, doc.uri, conf.MASMorTASM) === 0) {
56+
let Errmsgwindow = localize("dosbox.errmsg", '{0} Failed to compile. See the output for more information', conf.MASMorTASM);
5757
window.showErrorMessage(Errmsgwindow);
5858
}
5959
},
60-
() => { console.error('read dosbox mode T.txt FAILED') }
61-
)
60+
() => { console.error('read dosbox mode T.txt FAILED'); }
61+
);
6262
}
63-
return info
63+
return info;
6464
}
6565
}
6666

src/MSDOS-player.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { window, Terminal, Uri, TextDocument } from 'vscode'
1+
import { window, Terminal, Uri, TextDocument } from 'vscode';
22
import { Config } from './configration';
3-
import { exec } from 'child_process'
4-
import { DOSBox } from './DOSBox'
5-
import { landiagnose } from './language/diagnose'
3+
import { exec } from 'child_process';
4+
import { DOSBox } from './DOSBox';
5+
import { AssemblerDiag } from './language/diagnose';
66
import * as nls from 'vscode-nls';
7-
const localize = nls.loadMessageBundle()
7+
const localize = nls.loadMessageBundle();
88
export class MSDOSplayer {
9-
private _terminal: Terminal | null
9+
private _terminal: Terminal | null;
1010
constructor() {
11-
this._terminal = null
11+
this._terminal = null;
1212
}
1313
/**
1414
* 使用msdos-player执行汇编链接,如果汇编成功执行运行或者调试,如果失败输出错误信息
@@ -18,39 +18,39 @@ export class MSDOSplayer {
1818
* @param diag 处理输出信息的类,如果有将使用diag.ErrMsgProcess处理错误信息
1919
* @param doc 需要处理的文件
2020
*/
21-
public PlayerASM(conf: Config, isrun: boolean, viaplayer: boolean, diag: landiagnose, doc: TextDocument) {
22-
let filecontent: string
23-
filecontent = doc.getText()
24-
const filename = doc.fileName
25-
let command = '"' + conf.msbatpath + '" "' + conf.path + '" ' + conf.MASMorTASM + ' "' + filename + '" "' + conf.workpath + '"'
21+
public PlayerASM(conf: Config, isrun: boolean, viaplayer: boolean, diag: AssemblerDiag, doc: TextDocument) {
22+
let filecontent: string;
23+
filecontent = doc.getText();
24+
const filename = doc.fileName;
25+
let command = '"' + conf.msbatpath + '" "' + conf.path + '" ' + conf.MASMorTASM + ' "' + filename + '" "' + conf.workpath + '"';
2626
exec(command, { cwd: conf.path, shell: 'cmd.exe' }, (error, stdout, stderr) => {
2727
if (error) { console.error(`exec playerasm.bat: ${error}`); }
28-
let code = diag.ErrMsgProcess(filecontent, stdout, doc.uri, conf.MASMorTASM)
28+
let code = diag.ErrMsgProcess(filecontent, stdout, doc.uri, conf.MASMorTASM);
2929
switch (code) {
3030
case 0:
31-
let Errmsgwindow = localize("msdos.error", "{0} Error,Can't generate .exe file", conf.MASMorTASM)
31+
let Errmsgwindow = localize("msdos.error", "{0} Error,Can't generate .exe file", conf.MASMorTASM);
3232
window.showErrorMessage(Errmsgwindow);
33-
break
33+
break;
3434
case 1:
3535
let warningmsgwindow = localize("msdos.warn", "{0} Warning,successfully generate .exe file,but assembler has some warning message", conf.MASMorTASM);
36-
let Go_on = localize("msdos.continue", "continue")
37-
let Stop = localize("msdos.stop", "stop")
36+
let Go_on = localize("msdos.continue", "continue");
37+
let Stop = localize("msdos.stop", "stop");
3838
window.showInformationMessage(warningmsgwindow, Go_on, Stop).then(result => {
3939
if (result === Go_on) {
40-
this.afterlink(conf, viaplayer, isrun)
40+
this.afterlink(conf, viaplayer, isrun);
4141
}
4242
});
43-
break
43+
break;
4444
case 2:
45-
this.afterlink(conf, viaplayer, isrun)
46-
break
45+
this.afterlink(conf, viaplayer, isrun);
46+
break;
4747
}
48-
Config.writefile(Uri.joinPath(conf.toolsUri, './work/T.TXT'), stdout)
49-
})
48+
Config.writefile(Uri.joinPath(conf.toolsUri, './work/T.TXT'), stdout);
49+
});
5050
}
5151
private outTerminal(run: boolean, conf: Config) {
52-
let myenv = process.env
53-
let myenvPATH = myenv.PATH + ';' + conf.path + '\\player;' + conf.path + '\\tasm;' + conf.path + '\\masm;'
52+
let myenv = process.env;
53+
let myenvPATH = myenv.PATH + ';' + conf.path + '\\player;' + conf.path + '\\tasm;' + conf.path + '\\masm;';
5454
if (this._terminal?.exitStatus || this._terminal === null) {
5555
this._terminal = window.createTerminal({
5656
cwd: conf.workpath,
@@ -61,36 +61,36 @@ export class MSDOSplayer {
6161
hideFromUser: false,
6262
});
6363
}
64-
this._terminal.show()
64+
this._terminal.show();
6565
if (run) {
66-
this._terminal.sendText('msdos T.EXE')
66+
this._terminal.sendText('msdos T.EXE');
6767
}
6868
else {
69-
this._terminal.sendText('msdos -v5.0 debug T.EXE')
69+
this._terminal.sendText('msdos -v5.0 debug T.EXE');
7070
}
7171
}
7272
public deactivate() {
73-
if (this._terminal) this._terminal.dispose()
73+
if (this._terminal) { this._terminal.dispose(); }
7474
}
7575

7676
private afterlink(conf: Config, viaplayer: boolean, runordebug: boolean) {
77-
let debug: string
78-
if (conf.MASMorTASM == 'TASM') {
79-
debug = 'if exist c:\\tasm\\TDC2.TD copy c:\\tasm\\TDC2.TD TDCONFIG.TD \nTD T.EXE'
77+
let debug: string;
78+
if (conf.MASMorTASM === 'TASM') {
79+
debug = 'if exist c:\\tasm\\TDC2.TD copy c:\\tasm\\TDC2.TD TDCONFIG.TD \nTD T.EXE';
8080
}
8181
else {
82-
debug = 'DEBUG T.EXE'
82+
debug = 'DEBUG T.EXE';
8383
}
8484
if (viaplayer) {
85-
this.outTerminal(runordebug, conf)
85+
this.outTerminal(runordebug, conf);
8686
}
8787
else {
88-
let box = new DOSBox()
88+
let box = new DOSBox();
8989
if (runordebug) {
90-
box.openDOSBox(conf, 'T.EXE\n' + conf.boxruncmd)
90+
box.openDOSBox(conf, 'T.EXE\n' + conf.boxruncmd);
9191
}
9292
else {
93-
box.openDOSBox(conf, debug)
93+
box.openDOSBox(conf, debug);
9494
}
9595
}
9696
}

0 commit comments

Comments
 (0)