aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-04-02 07:58:58 +0100
committerEdwin Cheng <[email protected]>2019-04-02 08:03:31 +0100
commit06053a0a7636b620d36d49678a5d73424e0010e9 (patch)
treed065f86a59a6873b99df383cab087b87b3135f03 /editors
parent02e450f354ccd978c90425929c635139210843a3 (diff)
Add Cargo.toml file check before cargo watch start
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/commands/cargo_watch.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts
index fb8fcaeb3..6d8e4d885 100644
--- a/editors/code/src/commands/cargo_watch.ts
+++ b/editors/code/src/commands/cargo_watch.ts
@@ -1,4 +1,5 @@
1import * as child_process from 'child_process'; 1import * as child_process from 'child_process';
2import * as fs from 'fs';
2import * as path from 'path'; 3import * as path from 'path';
3import * as vscode from 'vscode'; 4import * as vscode from 'vscode';
4import { Server } from '../server'; 5import { Server } from '../server';
@@ -14,6 +15,27 @@ export class CargoWatchProvider {
14 private outputChannel?: vscode.OutputChannel; 15 private outputChannel?: vscode.OutputChannel;
15 16
16 public activate(subscriptions: vscode.Disposable[]) { 17 public activate(subscriptions: vscode.Disposable[]) {
18 let cargoExists = false;
19 const cargoTomlFile = path.join(
20 vscode.workspace.rootPath!,
21 'Cargo.toml'
22 );
23 // Check if the working directory is valid cargo root path
24 try {
25 if (fs.existsSync(cargoTomlFile)) {
26 cargoExists = true;
27 }
28 } catch (err) {
29 cargoExists = false;
30 }
31
32 if (!cargoExists) {
33 vscode.window.showErrorMessage(
34 `Couldn\'t find \'Cargo.toml\' in ${cargoTomlFile}`
35 );
36 return;
37 }
38
17 subscriptions.push(this); 39 subscriptions.push(this);
18 this.diagnosticCollection = vscode.languages.createDiagnosticCollection( 40 this.diagnosticCollection = vscode.languages.createDiagnosticCollection(
19 'rustc' 41 'rustc'