This commit is contained in:
parent
24e019e34f
commit
e79d2a7a7e
1 changed files with 3 additions and 2 deletions
|
@ -2,13 +2,14 @@ const { execFileSync } = require('child_process');
|
||||||
module.exports = function(command, commandArgs, verbose=false) {
|
module.exports = function(command, commandArgs, verbose=false) {
|
||||||
if (typeof command !== 'string' || !Array.isArray(commandArgs)) return { error: true };
|
if (typeof command !== 'string' || !Array.isArray(commandArgs)) return { error: true };
|
||||||
console.log("Executing:", command, commandArgs.join(" "));
|
console.log("Executing:", command, commandArgs.join(" "));
|
||||||
|
let output;
|
||||||
try {
|
try {
|
||||||
const output = execFileSync(command, commandArgs, {encoding: 'utf8'})
|
output = execFileSync(command, commandArgs, {encoding: 'utf8'})
|
||||||
if (output.length !== 0 && verbose)
|
if (output.length !== 0 && verbose)
|
||||||
console.log(output)
|
console.log(output)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error executing ${command} command:`, error);
|
console.error(`Error executing ${command} command:`, error);
|
||||||
return { error: true };
|
return { error: true };
|
||||||
}
|
}
|
||||||
return { error: false };
|
return { error: false, output};
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue