mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
38 lines
731 B
JavaScript
38 lines
731 B
JavaScript
const exec = require('child_process').exec;
|
|
const execFile = require('child_process').execFile;
|
|
|
|
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());
|
|
}
|
|
});
|
|
});
|
|
},
|
|
|
|
/**
|
|
* @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());
|
|
}
|
|
});
|
|
});
|
|
}
|
|
};
|