2263: Handle `cargo watch` errors caused by `cargo-watch` itself r=matklad a=oxalica

Currently, it silently fails when `cargo-watch` is installed but broken.

This PR handles missing cases and prompt the error message when failed.


Co-authored-by: oxalica <oxalicc@pm.me>
This commit is contained in:
bors[bot] 2019-11-16 12:49:20 +00:00 committed by GitHub
commit 7ad4461081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,7 +161,9 @@ export async function startCargoWatch(
): Promise<CargoWatchProvider | undefined> {
const execPromise = util.promisify(child_process.exec);
const { stderr } = await execPromise('cargo watch --version').catch(e => e);
const { stderr, code = 0 } = await execPromise(
'cargo watch --version'
).catch(e => e);
if (stderr.includes('no such subcommand: `watch`')) {
const msg =
@ -201,6 +203,11 @@ export async function startCargoWatch(
);
return;
}
} else if (code !== 0) {
vscode.window.showErrorMessage(
`\`cargo watch\` failed with ${code}: ${stderr}`
);
return;
}
const provider = await registerCargoWatchProvider(context.subscriptions);