Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2014-05-08 02:17:26 +0400
committerisaacs <i@izs.me>2014-05-08 02:18:38 +0400
commitbf761dddd14ce07b7070a38ec0661d4a21e7577f (patch)
tree3e78912ffb5be5c51caa8feee99ef1d34f39c85f /node_modules
parent7fc87498678ecd602f5f5c37cc930a61670af264 (diff)
Busy Spinner, no http noise
One step closer to #5213
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/char-spinner/LICENSE15
-rw-r--r--node_modules/char-spinner/README.md31
-rw-r--r--node_modules/char-spinner/package.json40
-rw-r--r--node_modules/char-spinner/spin.js41
-rw-r--r--node_modules/char-spinner/test/basic.js35
5 files changed, 162 insertions, 0 deletions
diff --git a/node_modules/char-spinner/LICENSE b/node_modules/char-spinner/LICENSE
new file mode 100644
index 000000000..05eeeb88c
--- /dev/null
+++ b/node_modules/char-spinner/LICENSE
@@ -0,0 +1,15 @@
+The ISC License
+
+Copyright (c) Isaac Z. Schlueter
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/node_modules/char-spinner/README.md b/node_modules/char-spinner/README.md
new file mode 100644
index 000000000..b202f4cdd
--- /dev/null
+++ b/node_modules/char-spinner/README.md
@@ -0,0 +1,31 @@
+# char-spinner
+
+Put a little spinner on process.stderr, as unobtrusively as possible.
+
+## USAGE
+
+```javascript
+var spinner = require("spinner")
+
+// All options are optional
+// even the options argument itself is optional
+spinner(options)
+```
+
+## OPTIONS
+
+Usually the defaults are what you want. Mostly they're just
+configurable for testing purposes.
+
+* `stream` Output stream. Default=`process.stderr`
+* `tty` Only show spinner if output stream has a truish `.isTTY`. Default=`true`
+* `string` String of chars to spin. Default=`'/-\\|'`
+* `interval` Number of ms between frames, bigger = slower. Default=`50`
+* `cleanup` Print `'\r \r'` to stream on process exit. Default=`true`
+* `unref` Unreference the spinner interval so that the process can
+ exit normally. Default=`true`
+* `delay` Number of frames to "skip over" before printing the spinner.
+ Useful if you want to avoid showing the spinner for very fast
+ actions. Default=`2`
+
+Returns the generated interval, if one was created.
diff --git a/node_modules/char-spinner/package.json b/node_modules/char-spinner/package.json
new file mode 100644
index 000000000..b2760afa6
--- /dev/null
+++ b/node_modules/char-spinner/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "char-spinner",
+ "version": "1.0.0",
+ "description": "Put a little spinner on process.stderr, as unobtrusively as possible.",
+ "main": "spin.js",
+ "directories": {
+ "test": "test"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "tap": "^0.4.10"
+ },
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/char-spinner"
+ },
+ "keywords": [
+ "char",
+ "spinner"
+ ],
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/isaacs/char-spinner/issues"
+ },
+ "homepage": "https://github.com/isaacs/char-spinner",
+ "readme": "# char-spinner\n\nPut a little spinner on process.stderr, as unobtrusively as possible.\n\n## USAGE\n\n```javascript\nvar spinner = require(\"spinner\")\n\n// All options are optional\n// even the options argument itself is optional\nspinner(options)\n```\n\n## OPTIONS\n\nUsually the defaults are what you want. Mostly they're just\nconfigurable for testing purposes.\n\n* `stream` Output stream. Default=`process.stderr`\n* `tty` Only show spinner if output stream has a truish `.isTTY`. Default=`true`\n* `string` String of chars to spin. Default=`'/-\\\\|'`\n* `interval` Number of ms between frames, bigger = slower. Default=`50`\n* `cleanup` Print `'\\r \\r'` to stream on process exit. Default=`true`\n* `unref` Unreference the spinner interval so that the process can\n exit normally. Default=`true`\n* `delay` Number of frames to \"skip over\" before printing the spinner.\n Useful if you want to avoid showing the spinner for very fast\n actions. Default=`2`\n\nReturns the generated interval, if one was created.\n",
+ "readmeFilename": "README.md",
+ "_id": "char-spinner@1.0.0",
+ "_shasum": "b5fadba903f242a31c1e93b2f532482d62bb56b2",
+ "_from": "char-spinner@latest",
+ "_resolved": "https://registry.npmjs.org/char-spinner/-/char-spinner-1.0.0.tgz"
+}
diff --git a/node_modules/char-spinner/spin.js b/node_modules/char-spinner/spin.js
new file mode 100644
index 000000000..1068d3253
--- /dev/null
+++ b/node_modules/char-spinner/spin.js
@@ -0,0 +1,41 @@
+module.exports = spinner
+
+function spinner(opt) {
+ opt = opt || {}
+ var str = opt.stream || process.stderr
+ var tty = typeof opt.tty === 'boolean' ? opt.tty : true
+ var string = opt.string || '/-\\|'
+ var ms = typeof opt.interval === 'number' ? opt.interval : 50
+ if (ms < 0) ms = 0
+ if (tty && !str.isTTY) return false
+
+ var s = 0
+ var sprite = string.split('')
+ var wrote = false
+
+ var delay = typeof opt.delay === 'number' ? opt.delay : 2
+
+ var interval = setInterval(function() {
+ if (--delay >= 0) return
+ s = ++s % sprite.length
+ var c = sprite[s]
+ str.write('\r \r' + c + '\r')
+ wrote = true
+ }, ms)
+
+ var unref = typeof opt.unref === 'boolean' ? opt.unref : true
+ if (unref && typeof interval.unref === 'function') {
+ interval.unref()
+ }
+
+ var cleanup = typeof opt.cleanup === 'boolean' ? opt.cleanup : true
+ if (cleanup) {
+ process.on('exit', function() {
+ if (wrote) {
+ str.write('\r \r')
+ }
+ })
+ }
+
+ return interval
+}
diff --git a/node_modules/char-spinner/test/basic.js b/node_modules/char-spinner/test/basic.js
new file mode 100644
index 000000000..f3c1dfe2b
--- /dev/null
+++ b/node_modules/char-spinner/test/basic.js
@@ -0,0 +1,35 @@
+var test = require('tap').test
+var spinner = require('../spin.js')
+
+test('does nothing when not a tty', function(t) {
+ var int = spinner({
+ stream: { write: function(c) {
+ throw new Error('wrote something: ' + JSON.stringify(c))
+ }, isTTY: false },
+ })
+ t.notOk(int)
+ t.end()
+})
+
+test('write spinny stuff', function(t) {
+ var output = ''
+ var written = 0
+ var expect = "\r \rb\r\r \rc\r\r \rd\r\r \re\r\r \rf\r\r \rg\r\r \rh\r\r \ri\r\r \rj\r\r \rk\r\r \rl\r\r \rm\r\r \rn\r\r \ro\r\r \rp\r\r \ra\r\r \rb\r\r \rc\r\r \rd\r\r \re\r\r \rf\r\r \rg\r\r \rh\r\r \ri\r\r \rj\r\r \rk\r\r \rl\r\r \rm\r\r \rn\r\r \ro\r\r \rp\r\r \ra\r\r \rb\r\r \rc\r\r \rd\r\r \re\r\r \rf\r\r \rg\r\r \rh\r\r \ri\r\r \rj\r\r \rk\r\r \rl\r\r \rm\r\r \rn\r\r \ro\r\r \rp\r\r \ra\r\r \rb\r\r \rc\r"
+
+ var int = spinner({
+ interval: 0,
+ string: 'abcdefghijklmnop',
+ stream: {
+ write: function(c) {
+ output += c
+ if (++written == 50) {
+ t.equal(output, expect)
+ clearInterval(int)
+ t.end()
+ }
+ },
+ isTTY: true
+ },
+ cleanup: false
+ })
+})