From 10836543d693675a9a2fd90130b1a816ede90fea Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 30 Apr 2020 18:41:48 +0300 Subject: [PATCH] Fixed tsfmt and eslint errors. --- editors/code/src/cargo.ts | 24 ++++++++++++------------ editors/code/src/commands/runnables.ts | 14 +++++++------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts index 857b84d59a..50f93856d7 100644 --- a/editors/code/src/cargo.ts +++ b/editors/code/src/cargo.ts @@ -21,24 +21,24 @@ export class Cargo { } public async artifactsFromArgs(cargoArgs: string[]): Promise { - let artifacts: CompilationArtifact[] = []; + const artifacts: CompilationArtifact[] = []; try { await this.runCargo(cargoArgs, message => { - if (message.reason == 'compiler-artifact' && message.executable) { - let isBinary = message.target.crate_types.includes('bin'); - let isBuildScript = message.target.kind.includes('custom-build'); + if (message.reason === 'compiler-artifact' && message.executable) { + const isBinary = message.target.crate_types.includes('bin'); + const isBuildScript = message.target.kind.includes('custom-build'); if ((isBinary && !isBuildScript) || message.profile.test) { artifacts.push({ fileName: message.executable, name: message.target.name, kind: message.target.kind[0], isTest: message.profile.test - }) + }); } } - else if( message.reason == 'compiler-message') { + else if (message.reason === 'compiler-message') { this.output.append(message.message.rendered); } }, @@ -62,9 +62,9 @@ export class Cargo { cargoArgs.push(...extraArgs); } - let artifacts = await this.artifactsFromArgs(cargoArgs); + const artifacts = await this.artifactsFromArgs(cargoArgs); - if (artifacts.length == 0 ) { + if (artifacts.length === 0) { throw new Error('No compilation artifacts'); } else if (artifacts.length > 1) { throw new Error('Multiple compilation artifacts are not supported.'); @@ -79,7 +79,7 @@ export class Cargo { onStderrString: (data: string) => void ): Promise { return new Promise((resolve, reject) => { - let cargo = cp.spawn('cargo', cargoArgs, { + const cargo = cp.spawn('cargo', cargoArgs, { stdio: ['ignore', 'pipe', 'pipe'], cwd: this.rootFolder, env: this.env, @@ -92,14 +92,14 @@ export class Cargo { onStderrString(chunk.toString()); }); - let rl = readline.createInterface({ input: cargo.stdout }); + const rl = readline.createInterface({ input: cargo.stdout }); rl.on('line', line => { - let message = JSON.parse(line); + const message = JSON.parse(line); onStdoutJson(message); }); cargo.on('exit', (exitCode, _) => { - if (exitCode == 0) + if (exitCode === 0) resolve(exitCode); else reject(new Error(`exit code: ${exitCode}.`)); diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index e8035c7d22..36d3093348 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -82,9 +82,9 @@ const debugOutput = vscode.window.createOutputChannel("Debug"); async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record): Promise { debugOutput.clear(); - - let cargo = new Cargo(config.cwd || '.', debugOutput); - let executable = await cargo.executableFromArgs(config.args, config.extraArgs); + + const cargo = new Cargo(config.cwd || '.', debugOutput); + const executable = await cargo.executableFromArgs(config.args, config.extraArgs); // if we are here, there were no compilation errors. return { @@ -106,9 +106,9 @@ export function debugSingle(ctx: Ctx): Cmd { const lldbId = "vadimcn.vscode-lldb"; const cpptoolsId = "ms-vscode.cpptools"; - let debugEngineId = ctx.config.debug.engine; + const debugEngineId = ctx.config.debug.engine; let debugEngine = null; - if ( debugEngineId === "auto" ) { + if (debugEngineId === "auto") { debugEngine = vscode.extensions.getExtension(lldbId); if (!debugEngine) { debugEngine = vscode.extensions.getExtension(cpptoolsId); @@ -120,11 +120,11 @@ export function debugSingle(ctx: Ctx): Cmd { if (!debugEngine) { vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=${lldbId})` - + ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=${cpptoolsId}) extension for debugging.`); + + ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=${cpptoolsId}) extension for debugging.`); return; } - const debugConfig = lldbId == debugEngine.id + const debugConfig = lldbId === debugEngine.id ? getLldbDebugConfig(config, ctx.config.debug.sourceFileMap) : await getCppvsDebugConfig(config, ctx.config.debug.sourceFileMap);