1
0
Fork 0

made it so much less clusterfuck

refactor/models
Bsian 2020-01-01 21:35:42 +00:00
parent a2213ae014
commit e9430a85e6
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 2 additions and 11 deletions

View File

@ -32,18 +32,9 @@ export default class Util {
public async exec(command: string, options?: childProcess.ExecOptions): Promise<string> { public async exec(command: string, options?: childProcess.ExecOptions): Promise<string> {
const ex = promisify(childProcess.exec); const ex = promisify(childProcess.exec);
let result: string; let result: string;
// eslint-disable-next-line no-useless-catch
let args: childProcess.ExecOptions;
try { try {
if (options) { if (!options || (!options.env)) options.env = { HOME: '/root' };
args = options; const res = await ex(command, options);
if (!args.env) {
args.env = { HOME: '/root' };
}
} else {
args.env = { HOME: '/root' };
}
const res = await ex(command, args);
result = res.stderr || res.stdout; result = res.stderr || res.stdout;
} catch (err) { } catch (err) {
return Promise.reject(new Error(`Command failed: ${err.cmd}\n${err.stderr || err.stdout}`)); return Promise.reject(new Error(`Command failed: ${err.cmd}\n${err.stderr || err.stdout}`));