diff options
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/cargo_watch.ts | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts index 4c3c10c8b..00b24dbce 100644 --- a/editors/code/src/commands/cargo_watch.ts +++ b/editors/code/src/commands/cargo_watch.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import * as child_process from 'child_process'; | 1 | import * as child_process from 'child_process'; |
2 | import * as fs from 'fs'; | ||
3 | import * as path from 'path'; | 2 | import * as path from 'path'; |
4 | import * as vscode from 'vscode'; | 3 | import * as vscode from 'vscode'; |
5 | 4 | ||
@@ -15,23 +14,23 @@ import { | |||
15 | import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection'; | 14 | import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection'; |
16 | import { areDiagnosticsEqual } from '../utils/diagnostics/vscode'; | 15 | import { areDiagnosticsEqual } from '../utils/diagnostics/vscode'; |
17 | 16 | ||
18 | export function registerCargoWatchProvider( | 17 | export async function registerCargoWatchProvider( |
19 | subscriptions: vscode.Disposable[] | 18 | subscriptions: vscode.Disposable[] |
20 | ): CargoWatchProvider | undefined { | 19 | ): Promise<CargoWatchProvider | undefined> { |
21 | let cargoExists = false; | 20 | let cargoExists = false; |
22 | const cargoTomlFile = path.join(vscode.workspace.rootPath!, 'Cargo.toml'); | 21 | |
23 | // Check if the working directory is valid cargo root path | 22 | // Check if the working directory is valid cargo root path |
24 | try { | 23 | const cargoTomlPath = path.join(vscode.workspace.rootPath!, 'Cargo.toml'); |
25 | if (fs.existsSync(cargoTomlFile)) { | 24 | const cargoTomlUri = vscode.Uri.file(cargoTomlPath); |
26 | cargoExists = true; | 25 | const cargoTomlFileInfo = await vscode.workspace.fs.stat(cargoTomlUri); |
27 | } | 26 | |
28 | } catch (err) { | 27 | if (cargoTomlFileInfo) { |
29 | cargoExists = false; | 28 | cargoExists = true; |
30 | } | 29 | } |
31 | 30 | ||
32 | if (!cargoExists) { | 31 | if (!cargoExists) { |
33 | vscode.window.showErrorMessage( | 32 | vscode.window.showErrorMessage( |
34 | `Couldn\'t find \'Cargo.toml\' in ${cargoTomlFile}` | 33 | `Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}` |
35 | ); | 34 | ); |
36 | return; | 35 | return; |
37 | } | 36 | } |