diff options
| author | Lucas Spits <spits.lucas@gmail.com> | 2019-09-09 20:24:31 +0200 |
|---|---|---|
| committer | Lucas Spits <spits.lucas@gmail.com> | 2019-09-09 20:24:31 +0200 |
| commit | 80b45d59285e95dc3af611cb739324fcf5777660 (patch) | |
| tree | 639a06465a396e1c86cdaa02ff8f62d31cd3f6b1 /editors/code/src | |
| parent | 7258523a519207a033dedde8c498debe8da4a15e (diff) | |
| download | rust-80b45d59285e95dc3af611cb739324fcf5777660.tar.gz rust-80b45d59285e95dc3af611cb739324fcf5777660.zip | |
Replace watcher file existence check with vscode.fs version
Diffstat (limited to 'editors/code/src')
| -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 4c3c10c8b10..00b24dbced4 100644 --- a/editors/code/src/commands/cargo_watch.ts +++ b/editors/code/src/commands/cargo_watch.ts @@ -1,5 +1,4 @@ import * as child_process from 'child_process'; -import * as fs from 'fs'; import * as path from 'path'; import * as vscode from 'vscode'; @@ -15,23 +14,23 @@ import { import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection'; import { areDiagnosticsEqual } from '../utils/diagnostics/vscode'; -export function registerCargoWatchProvider( +export async function registerCargoWatchProvider( subscriptions: vscode.Disposable[] -): CargoWatchProvider | undefined { +): Promise<CargoWatchProvider | undefined> { let cargoExists = false; - const cargoTomlFile = path.join(vscode.workspace.rootPath!, 'Cargo.toml'); + // Check if the working directory is valid cargo root path - try { - if (fs.existsSync(cargoTomlFile)) { - cargoExists = true; - } - } catch (err) { - cargoExists = false; + const cargoTomlPath = path.join(vscode.workspace.rootPath!, 'Cargo.toml'); + const cargoTomlUri = vscode.Uri.file(cargoTomlPath); + const cargoTomlFileInfo = await vscode.workspace.fs.stat(cargoTomlUri); + + if (cargoTomlFileInfo) { + cargoExists = true; } if (!cargoExists) { vscode.window.showErrorMessage( - `Couldn\'t find \'Cargo.toml\' in ${cargoTomlFile}` + `Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}` ); return; } |
