shell: make require take a tag

This commit is contained in:
Girish Ramakrishnan
2024-10-14 19:10:31 +02:00
parent 02823c4158
commit a9e1d7641d
27 changed files with 162 additions and 156 deletions
+18 -11
View File
@@ -7,17 +7,6 @@ const assert = require('assert'),
once = require('./once.js'),
util = require('util');
exports = module.exports = {
exec,
execArgs,
sudo,
promises: {
sudo: util.promisify(sudo)
}
};
const SUDO = '/usr/bin/sudo';
// default encoding utf8, no shell, handles input, separate args, wait for process to finish
@@ -156,3 +145,21 @@ function sudo(tag, args, options, callback) {
return cp;
}
function shell(tag) {
assert.strictEqual(typeof tag, 'string');
return {
exec: exec.bind(null, tag),
execArgs: execArgs.bind(null, tag),
sudo: sudo.bind(null, tag),
promises: { sudo: util.promisify(sudo.bind(null, tag)) }
};
}
shell.exec = exec;
shell.execArgs = execArgs;
shell.sudo = sudo;
shell.promises = { sudo: util.promisify(sudo) };
exports = module.exports = shell;