Separate executeCommand into its own util function
All checks were successful
CI / CI (push) Successful in 22s
All checks were successful
CI / CI (push) Successful in 22s
This commit is contained in:
parent
f55b54eb49
commit
924a4b82fd
3 changed files with 19 additions and 33 deletions
14
util/executeCommand.js
Normal file
14
util/executeCommand.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
const { execFileSync } = require('child_process');
|
||||
module.exports = function(command, commandArgs, verbose=false) {
|
||||
if (typeof command !== 'string' || !Array.isArray(commandArgs)) return { error: true };
|
||||
console.log("Executing:", command, commandArgs.join(" "));
|
||||
try {
|
||||
const output = execFileSync(command, commandArgs, {encoding: 'utf8'})
|
||||
if (output.length != 0 && verbose)
|
||||
console.log(output)
|
||||
} catch (error) {
|
||||
console.error(`Error executing ${command} command:`, error);
|
||||
return { error: true };
|
||||
}
|
||||
return { error: false };
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue