diff --git a/lib/CLI/CliUx.js b/lib/CLI/CliUx.js index cef5d3d6..b9a16da8 100644 --- a/lib/CLI/CliUx.js +++ b/lib/CLI/CliUx.js @@ -268,7 +268,18 @@ UX.dispKeys = function(kv, target_module) { }); } -var defaultSpinnerString = '|/-\\'; +var defaultSpinnerString = [ + "⠋", + "⠙", + "⠹", + "⠸", + "⠼", + "⠴", + "⠦", + "⠧", + "⠇", + "⠏" +].join(''); var Spinner = function(textToShow){ this.text = textToShow || ''; @@ -305,22 +316,10 @@ Spinner.prototype.stop = function() { clearInterval(this.id); }; -UX.dotSpinner = { - start : function() { - this.interval = setInterval(function() { - console.log('asddsa'); - process.stdout.write('.'); - }, 100); - }, - stop : function() { - clearInterval(this.interval); - } -}; - UX.processing = { current_spinner : null, - start : function() { - this.current_spinner = new Spinner('Connecting...'); + start : function(text) { + this.current_spinner = new Spinner(text || 'Connecting...'); this.current_spinner.start(); }, stop : function() { diff --git a/lib/Modularizer.js b/lib/Modularizer.js index 2c0c63e6..cefefef3 100644 --- a/lib/Modularizer.js +++ b/lib/Modularizer.js @@ -106,17 +106,16 @@ function installModule(module_name, cb) { * Production mode */ - Common.printOut(cst.PREFIX_MSG_MOD + 'Processing...'); - var inter = setInterval(function() { - process.stdout.write('.'); - }, 500); + UX.processing.start('Downloading module'); - shelljs.exec('npm install ' + module_name + ' --prefix ' + cst.PM2_ROOT_PATH, {silent : true}, function(code) { - clearInterval(inter); + var command = 'npm install ' + module_name + ' --prefix ' + cst.PM2_ROOT_PATH; + + shelljs.exec(command, {async : true}, function(code, out, err) { + UX.processing.stop(); if (code != 0) { - Common.printError(cst.PREFIX_MSG_MOD_ERR + 'Unknown module'); - return cb({msg:'Unknown module'}); + Common.printError(cst.PREFIX_MSG_MOD_ERR + 'Installation failed'); + return cb(new Error(err)); } Common.printOut(cst.PREFIX_MSG_MOD + 'Module downloaded');