diff --git a/src/api/run.ts b/src/api/run.ts index 85c6df84..f129ec86 100644 --- a/src/api/run.ts +++ b/src/api/run.ts @@ -334,7 +334,7 @@ export function execute( } return Context.WithoutActiveEditor.wrap(import("child_process").then((cp) => - new Promise<{ readonly val: string } | { readonly err: string }>((resolve) => { + new Promise((resolve, reject) => { const shell = getShell() ?? true, child = cp.spawn(command, { shell, stdio: "pipe" }); @@ -352,18 +352,16 @@ export function execute( child.once("error", (err) => { disposable.dispose(); - resolve({ err: err.message }); + reject(err); }); child.once("exit", (code) => { disposable.dispose(); code === 0 - ? resolve({ val: stdout.trimRight() }) - : resolve({ - err: `Command exited with error ${code}: ${ + ? resolve(stdout.trimRight()) + : reject(new Error(`Command exited with error ${code}: ${ stderr.length > 0 ? stderr.trimRight() : "" - }`, - }); + }`)); }); })), );