From e9430a85e6a564f6c78cdb8202e5b2ef3fd648c6 Mon Sep 17 00:00:00 2001 From: Bsian Date: Wed, 1 Jan 2020 21:35:42 +0000 Subject: [PATCH] made it so much less clusterfuck --- src/class/Util.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 83feb14..e8580de 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -32,18 +32,9 @@ export default class Util { public async exec(command: string, options?: childProcess.ExecOptions): Promise { 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}`));