made it so much less clusterfuck
parent
a2213ae014
commit
e9430a85e6
|
@ -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}`));
|
||||||
|
|
Loading…
Reference in New Issue