Use president to provide sudo functionality

This commit is contained in:
Juan Cruz Viotti 2015-10-26 09:47:49 -04:00
parent 3192f9d2ef
commit c866f6e46c
3 changed files with 8 additions and 17 deletions

View File

@ -1,5 +1,5 @@
(function() {
var Promise, _, capitano, chalk, child_process, os, rindle;
var Promise, _, capitano, chalk, os, president;
Promise = require('bluebird');
@ -9,9 +9,7 @@
_.str = require('underscore.string');
child_process = require('child_process');
rindle = require('rindle');
president = Promise.promisifyAll(require('president'));
os = require('os');
@ -40,16 +38,12 @@
};
exports.sudo = function(command) {
var spawn;
if (os.platform() === 'win32') {
return capitano.runAsync(command.join(' '));
}
console.log('Type your computer password to continue');
command = _.union(_.take(process.argv, 2), command);
spawn = child_process.spawn('sudo', command, {
stdio: 'inherit'
});
return rindle.wait(spawn);
console.log('Type your computer password to continue');
return president.executeAsync(command);
};
}).call(this);

View File

@ -2,8 +2,7 @@ Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano'))
_ = require('lodash')
_.str = require('underscore.string')
child_process = require('child_process')
rindle = require('rindle')
president = Promise.promisifyAll(require('president'))
os = require('os')
chalk = require('chalk')
@ -36,10 +35,7 @@ exports.sudo = (command) ->
if os.platform() is 'win32'
return capitano.runAsync(command.join(' '))
console.log('Type your computer password to continue')
command = _.union(_.take(process.argv, 2), command)
spawn = child_process.spawn 'sudo', command,
stdio: 'inherit'
return rindle.wait(spawn)
console.log('Type your computer password to continue')
return president.executeAsync(command)

View File

@ -46,6 +46,7 @@
"is-root": "^1.0.0",
"lodash": "^3.10.0",
"nplugm": "^3.0.0",
"president": "^2.0.0",
"resin-cli-errors": "^1.0.0",
"resin-cli-events": "^1.0.2",
"resin-cli-form": "^1.3.0",