mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Merge #2263
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:
commit
7ad4461081
@ -161,7 +161,9 @@ export async function startCargoWatch(
|
|||||||
): Promise<CargoWatchProvider | undefined> {
|
): Promise<CargoWatchProvider | undefined> {
|
||||||
const execPromise = util.promisify(child_process.exec);
|
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`')) {
|
if (stderr.includes('no such subcommand: `watch`')) {
|
||||||
const msg =
|
const msg =
|
||||||
@ -201,6 +203,11 @@ export async function startCargoWatch(
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (code !== 0) {
|
||||||
|
vscode.window.showErrorMessage(
|
||||||
|
`\`cargo watch\` failed with ${code}: ${stderr}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const provider = await registerCargoWatchProvider(context.subscriptions);
|
const provider = await registerCargoWatchProvider(context.subscriptions);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user