same as prev
parent
e9430a85e6
commit
41f42c2f9d
|
@ -29,11 +29,11 @@ export default class Util {
|
||||||
* @param command The command to execute
|
* @param command The command to execute
|
||||||
* @param options childProcess.ExecOptions, the env option is automatically set if not provided.
|
* @param options childProcess.ExecOptions, the env option is automatically set if not provided.
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
try {
|
try {
|
||||||
if (!options || (!options.env)) options.env = { HOME: '/root' };
|
if (!options.env) options.env = { HOME: '/root' };
|
||||||
const res = await ex(command, options);
|
const res = await ex(command, options);
|
||||||
result = res.stderr || res.stdout;
|
result = res.stderr || res.stdout;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue