made it so much less clusterfuck

merge-requests/2/merge
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> {
const ex = promisify(childProcess.exec);
let result: string;
// eslint-disable-next-line no-useless-catch
let args: childProcess.ExecOptions;
try {
if (options) {
args = options;
if (!args.env) {
args.env = { HOME: '/root' };
}
} else {
args.env = { HOME: '/root' };
}
const res = await ex(command, args);
if (!options || (!options.env)) options.env = { HOME: '/root' };
const res = await ex(command, options);
result = res.stderr || res.stdout;
} catch (err) {
return Promise.reject(new Error(`Command failed: ${err.cmd}\n${err.stderr || err.stdout}`));