mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 06:57:48 +00:00
Merge pull request #253 from resin-io/jviotti/refactor/sudo-president
Use president to provide sudo functionality
This commit is contained in:
commit
f84d0d0980
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var Promise, _, capitano, chalk, child_process, os, rindle;
|
var Promise, _, capitano, chalk, os, president;
|
||||||
|
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
|
||||||
@ -9,9 +9,7 @@
|
|||||||
|
|
||||||
_.str = require('underscore.string');
|
_.str = require('underscore.string');
|
||||||
|
|
||||||
child_process = require('child_process');
|
president = Promise.promisifyAll(require('president'));
|
||||||
|
|
||||||
rindle = require('rindle');
|
|
||||||
|
|
||||||
os = require('os');
|
os = require('os');
|
||||||
|
|
||||||
@ -40,16 +38,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.sudo = function(command) {
|
exports.sudo = function(command) {
|
||||||
var spawn;
|
|
||||||
if (os.platform() === 'win32') {
|
if (os.platform() === 'win32') {
|
||||||
return capitano.runAsync(command.join(' '));
|
return capitano.runAsync(command.join(' '));
|
||||||
}
|
}
|
||||||
console.log('Type your computer password to continue');
|
|
||||||
command = _.union(_.take(process.argv, 2), command);
|
command = _.union(_.take(process.argv, 2), command);
|
||||||
spawn = child_process.spawn('sudo', command, {
|
console.log('Type your computer password to continue');
|
||||||
stdio: 'inherit'
|
return president.executeAsync(command);
|
||||||
});
|
|
||||||
return rindle.wait(spawn);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
@ -2,8 +2,7 @@ Promise = require('bluebird')
|
|||||||
capitano = Promise.promisifyAll(require('capitano'))
|
capitano = Promise.promisifyAll(require('capitano'))
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
_.str = require('underscore.string')
|
_.str = require('underscore.string')
|
||||||
child_process = require('child_process')
|
president = Promise.promisifyAll(require('president'))
|
||||||
rindle = require('rindle')
|
|
||||||
os = require('os')
|
os = require('os')
|
||||||
chalk = require('chalk')
|
chalk = require('chalk')
|
||||||
|
|
||||||
@ -36,10 +35,7 @@ exports.sudo = (command) ->
|
|||||||
if os.platform() is 'win32'
|
if os.platform() is 'win32'
|
||||||
return capitano.runAsync(command.join(' '))
|
return capitano.runAsync(command.join(' '))
|
||||||
|
|
||||||
console.log('Type your computer password to continue')
|
|
||||||
command = _.union(_.take(process.argv, 2), command)
|
command = _.union(_.take(process.argv, 2), command)
|
||||||
|
|
||||||
spawn = child_process.spawn 'sudo', command,
|
console.log('Type your computer password to continue')
|
||||||
stdio: 'inherit'
|
return president.executeAsync(command)
|
||||||
|
|
||||||
return rindle.wait(spawn)
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
"is-root": "^1.0.0",
|
"is-root": "^1.0.0",
|
||||||
"lodash": "^3.10.0",
|
"lodash": "^3.10.0",
|
||||||
"nplugm": "^3.0.0",
|
"nplugm": "^3.0.0",
|
||||||
|
"president": "^2.0.0",
|
||||||
"resin-cli-errors": "^1.0.0",
|
"resin-cli-errors": "^1.0.0",
|
||||||
"resin-cli-events": "^1.0.2",
|
"resin-cli-events": "^1.0.2",
|
||||||
"resin-cli-form": "^1.3.0",
|
"resin-cli-form": "^1.3.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user