2020-02-19 04:55:06 +00:00
|
|
|
const exec = require('child_process').exec;
|
2023-02-26 19:10:25 +00:00
|
|
|
const execFile = require('child_process').execFile;
|
2020-02-19 04:55:06 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {String} cmd
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
|
|
|
exec: function (cmd) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
exec(cmd, function (err, stdout, /*stderr*/) {
|
|
|
|
if (err && typeof err === 'object') {
|
|
|
|
reject(err);
|
|
|
|
} else {
|
|
|
|
resolve(stdout.trim());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2023-02-26 19:10:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Array} cmd
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
|
|
|
execFile: function (cmd) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
execFile(cmd, function (err, stdout, /*stderr*/) {
|
|
|
|
if (err && typeof err === 'object') {
|
|
|
|
reject(err);
|
|
|
|
} else {
|
|
|
|
resolve(stdout.trim());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2020-02-19 04:55:06 +00:00
|
|
|
}
|
|
|
|
};
|