]> git.lizzy.rs Git - rust.git/commitdiff
Protect against null as revealed by `npm test`
authorkjeremy <kjeremy@gmail.com>
Fri, 20 Dec 2019 18:52:34 +0000 (13:52 -0500)
committerkjeremy <kjeremy@gmail.com>
Fri, 20 Dec 2019 18:52:34 +0000 (13:52 -0500)
editors/code/src/commands/cargo_watch.ts

index 748be535cc5750c53fb516495f0c0a2e622b7c43..ac62bdd48d20144951c6c67cfa86d470c610581e 100644 (file)
@@ -111,8 +111,13 @@ export class CargoWatchProvider implements vscode.Disposable {
             },
         );
 
+        if (!this.cargoProcess) {
+            vscode.window.showErrorMessage('Cargo Watch failed to start');
+            return;
+        }
+
         const stdoutData = new LineBuffer();
-        this.cargoProcess.stdout.on('data', (s: string) => {
+        this.cargoProcess.stdout?.on('data', (s: string) => {
             stdoutData.processOutput(s, line => {
                 this.logInfo(line);
                 try {
@@ -124,7 +129,7 @@ export class CargoWatchProvider implements vscode.Disposable {
         });
 
         const stderrData = new LineBuffer();
-        this.cargoProcess.stderr.on('data', (s: string) => {
+        this.cargoProcess.stderr?.on('data', (s: string) => {
             stderrData.processOutput(s, line => {
                 this.logError('Error on cargo-watch : {\n' + line + '}\n');
             });