diff --git a/src/shell.js b/src/shell.js index fd923a97e..28867d6af 100644 --- a/src/shell.js +++ b/src/shell.js @@ -1,18 +1,24 @@ 'use strict'; -exports = module.exports = { - spawn, - exec, - sudo -}; - -var assert = require('assert'), +const assert = require('assert'), BoxError = require('./boxerror.js'), child_process = require('child_process'), debug = require('debug')('box:shell'), once = require('once'), util = require('util'); +exports = module.exports = { + spawn, + exec, + sudo, + + promises: { + exec: util.promisify(exec), + spawn: util.promisify(spawn), + sudo: util.promisify(sudo) + } +}; + const SUDO = '/usr/bin/sudo'; function exec(tag, cmd, callback) { @@ -88,7 +94,7 @@ function sudo(tag, args, options, callback) { if (options.preserveEnv) sudoArgs.push('-E'); // -E preserves environment if (options.ipc) sudoArgs.push('--close-from=4'); // keep the ipc open. requires closefrom_override in sudoers file - var cp = spawn(tag, SUDO, sudoArgs.concat(args), options, callback); + const cp = spawn(tag, SUDO, sudoArgs.concat(args), options, callback); cp.stdin.end(); return cp; }