aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/cargo.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/cargo.ts')
-rw-r--r--editors/code/src/cargo.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts
index 857b84d59..50f93856d 100644
--- a/editors/code/src/cargo.ts
+++ b/editors/code/src/cargo.ts
@@ -21,24 +21,24 @@ export class Cargo {
21 } 21 }
22 22
23 public async artifactsFromArgs(cargoArgs: string[]): Promise<CompilationArtifact[]> { 23 public async artifactsFromArgs(cargoArgs: string[]): Promise<CompilationArtifact[]> {
24 let artifacts: CompilationArtifact[] = []; 24 const artifacts: CompilationArtifact[] = [];
25 25
26 try { 26 try {
27 await this.runCargo(cargoArgs, 27 await this.runCargo(cargoArgs,
28 message => { 28 message => {
29 if (message.reason == 'compiler-artifact' && message.executable) { 29 if (message.reason === 'compiler-artifact' && message.executable) {
30 let isBinary = message.target.crate_types.includes('bin'); 30 const isBinary = message.target.crate_types.includes('bin');
31 let isBuildScript = message.target.kind.includes('custom-build'); 31 const isBuildScript = message.target.kind.includes('custom-build');
32 if ((isBinary && !isBuildScript) || message.profile.test) { 32 if ((isBinary && !isBuildScript) || message.profile.test) {
33 artifacts.push({ 33 artifacts.push({
34 fileName: message.executable, 34 fileName: message.executable,
35 name: message.target.name, 35 name: message.target.name,
36 kind: message.target.kind[0], 36 kind: message.target.kind[0],
37 isTest: message.profile.test 37 isTest: message.profile.test
38 }) 38 });
39 } 39 }
40 } 40 }
41 else if( message.reason == 'compiler-message') { 41 else if (message.reason === 'compiler-message') {
42 this.output.append(message.message.rendered); 42 this.output.append(message.message.rendered);
43 } 43 }
44 }, 44 },
@@ -62,9 +62,9 @@ export class Cargo {
62 cargoArgs.push(...extraArgs); 62 cargoArgs.push(...extraArgs);
63 } 63 }
64 64
65 let artifacts = await this.artifactsFromArgs(cargoArgs); 65 const artifacts = await this.artifactsFromArgs(cargoArgs);
66 66
67 if (artifacts.length == 0 ) { 67 if (artifacts.length === 0) {
68 throw new Error('No compilation artifacts'); 68 throw new Error('No compilation artifacts');
69 } else if (artifacts.length > 1) { 69 } else if (artifacts.length > 1) {
70 throw new Error('Multiple compilation artifacts are not supported.'); 70 throw new Error('Multiple compilation artifacts are not supported.');
@@ -79,7 +79,7 @@ export class Cargo {
79 onStderrString: (data: string) => void 79 onStderrString: (data: string) => void
80 ): Promise<number> { 80 ): Promise<number> {
81 return new Promise<number>((resolve, reject) => { 81 return new Promise<number>((resolve, reject) => {
82 let cargo = cp.spawn('cargo', cargoArgs, { 82 const cargo = cp.spawn('cargo', cargoArgs, {
83 stdio: ['ignore', 'pipe', 'pipe'], 83 stdio: ['ignore', 'pipe', 'pipe'],
84 cwd: this.rootFolder, 84 cwd: this.rootFolder,
85 env: this.env, 85 env: this.env,
@@ -92,14 +92,14 @@ export class Cargo {
92 onStderrString(chunk.toString()); 92 onStderrString(chunk.toString());
93 }); 93 });
94 94
95 let rl = readline.createInterface({ input: cargo.stdout }); 95 const rl = readline.createInterface({ input: cargo.stdout });
96 rl.on('line', line => { 96 rl.on('line', line => {
97 let message = JSON.parse(line); 97 const message = JSON.parse(line);
98 onStdoutJson(message); 98 onStdoutJson(message);
99 }); 99 });
100 100
101 cargo.on('exit', (exitCode, _) => { 101 cargo.on('exit', (exitCode, _) => {
102 if (exitCode == 0) 102 if (exitCode === 0)
103 resolve(exitCode); 103 resolve(exitCode);
104 else 104 else
105 reject(new Error(`exit code: ${exitCode}.`)); 105 reject(new Error(`exit code: ${exitCode}.`));