Better '$' error handling
This commit is contained in:
@ -3,7 +3,7 @@ import {exec, execSync} from 'child_process';
|
||||
export function $(str: TemplateStringsArray, ...args: string[]): Promise<string> {
|
||||
let cmd = str.reduce((acc, part, i) => acc + part + (args[i] || ''), '');
|
||||
return new Promise((res, rej) => exec(cmd, (err, stdout, stderr) => {
|
||||
if(err || stderr) return rej(err || stderr);
|
||||
if(err) return rej(stderr || err);
|
||||
return res(stdout);
|
||||
}))
|
||||
}
|
||||
|
Reference in New Issue
Block a user