diff --git a/lib/utils.js b/lib/utils.js index d8d70361..66166db1 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import { util, net } from 'appium/support'; import { promisify } from 'node:util'; import { exec } from 'node:child_process'; @@ -21,8 +22,12 @@ export async function shellExec(cmd, args = [], opts = {}) { timeoutMs = 60 * 1000 * 5 } = opts; const fullCmd = util.quote([cmd, ...args]); - return await B.resolve(execAsync(fullCmd, opts)) + const { stdout, stderr } = await B.resolve(execAsync(fullCmd, opts)) .timeout(timeoutMs, `The command '${fullCmd}' timed out after ${timeoutMs}ms`); + return { + stdout: _.isString(stdout) ? stdout : stdout.toString(), + stderr: _.isString(stderr) ? stderr : stderr.toString(), + }; } /**