From c866f6e46c5957018874a02282eb50ff523df1a9 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 26 Oct 2015 09:47:49 -0400 Subject: [PATCH] Use president to provide sudo functionality --- build/utils/helpers.js | 14 ++++---------- lib/utils/helpers.coffee | 10 +++------- package.json | 1 + 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/build/utils/helpers.js b/build/utils/helpers.js index 3a9be677..df2dc4e9 100644 --- a/build/utils/helpers.js +++ b/build/utils/helpers.js @@ -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); diff --git a/lib/utils/helpers.coffee b/lib/utils/helpers.coffee index e26a68f9..b8ee980d 100644 --- a/lib/utils/helpers.coffee +++ b/lib/utils/helpers.coffee @@ -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) diff --git a/package.json b/package.json index de2aa376..094ec805 100644 --- a/package.json +++ b/package.json @@ -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",