diff options
Diffstat (limited to 'lib/npm.js')
-rw-r--r-- | lib/npm.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/npm.js b/lib/npm.js index 613bf0095..44c132f2c 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -30,6 +30,7 @@ var EventEmitter = require("events").EventEmitter , slide = require("slide") , chain = slide.chain , RegClient = require("npm-registry-client") + , charSpin = require("char-spinner") npm.config = { loaded: false, @@ -182,6 +183,21 @@ var commandCache = {} }) , abbrevs = abbrev(fullList) +npm.spinner = + { int: null + , start: function () { + if (npm.spinner.int) return + var c = npm.config.get("spin") + if (!c) return + var stream = npm.config.get("logstream") + var opt = { tty: c !== "always", stream: stream } + npm.spinner.int = charSpin(opt) + } + , stop: function () { + clearInterval(npm.spinner.int) + } + } + Object.keys(abbrevs).concat(plumbing).forEach(function addCommand (c) { Object.defineProperty(npm.commands, c, { get : function () { if (!loaded) throw new Error( @@ -204,6 +220,8 @@ Object.keys(abbrevs).concat(plumbing).forEach(function addCommand (c) { } if (args.length === 1) args.unshift([]) + npm.spinner.start() + if (!npm.registry.refer) { npm.registry.refer = [a].concat(args[0]).map(function (arg) { // exclude anything that might be a URL, path, or private module |