mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-18 10:46:34 +00:00
Use president to provide sudo functionality
This commit is contained in:
parent
3192f9d2ef
commit
c866f6e46c
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user