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>2012-08-02 02:55:19 +0400
committerisaacs <i@izs.me>2012-08-02 02:55:19 +0400
commita6f0cee57412a1ba13a8eedcfc86f47a8a68059d (patch)
treea4ce64c1406dbfe274268f76c9f6b40b6cd98d2c /node_modules/read
parentaa3a686b4b8e29067b452cce886d7fd1455189db (diff)
read@1.0.2
Diffstat (limited to 'node_modules/read')
-rw-r--r--node_modules/read/README.md1
-rw-r--r--node_modules/read/lib/read.js2
-rw-r--r--node_modules/read/node_modules/mute-stream/README.md10
-rw-r--r--node_modules/read/node_modules/mute-stream/mute.js18
-rw-r--r--node_modules/read/node_modules/mute-stream/package.json11
-rw-r--r--node_modules/read/node_modules/mute-stream/test/basic.js59
-rw-r--r--node_modules/read/package.json10
7 files changed, 97 insertions, 14 deletions
diff --git a/node_modules/read/README.md b/node_modules/read/README.md
index 917e703fc..01aa8e76b 100644
--- a/node_modules/read/README.md
+++ b/node_modules/read/README.md
@@ -22,6 +22,7 @@ Every option is optional.
* `prompt` What to write to stdout before reading input.
* `silent` Don't echo the output as the user types it.
+* `replace` Replace silenced characters with the supplied character value.
* `timeout` Number of ms to wait for user input before giving up.
* `default` The default value if the user enters nothing.
* `edit` Allow the user to edit the default value.
diff --git a/node_modules/read/lib/read.js b/node_modules/read/lib/read.js
index 5cff5299a..363e7e85f 100644
--- a/node_modules/read/lib/read.js
+++ b/node_modules/read/lib/read.js
@@ -11,7 +11,7 @@ function read (opts, cb) {
var input = opts.input || process.stdin
var output = opts.output || process.stdout
- var m = new Mute()
+ var m = new Mute({ replace: opts.replace })
m.pipe(output)
output = m
var def = opts.default || ''
diff --git a/node_modules/read/node_modules/mute-stream/README.md b/node_modules/read/node_modules/mute-stream/README.md
index 43f0cd48f..91b45c40c 100644
--- a/node_modules/read/node_modules/mute-stream/README.md
+++ b/node_modules/read/node_modules/mute-stream/README.md
@@ -10,7 +10,7 @@ silently dropped, rather than being passed through.
```javascript
var MuteStream = require('mute-stream')
-var ms = new MuteStream
+var ms = new MuteStream(options)
ms.pipe(process.stdout)
ms.write('foo') // writes 'foo' to stdout
@@ -34,6 +34,14 @@ ms.unmute()
input.emit('data', 'baz') // logs 'baz'
```
+## Options
+
+All options are optional.
+
+* `replace` Set to a string to replace each character with the
+ specified string when muted. (So you can show `****` instead of the
+ password, for example.)
+
## ms.mute()
Set `muted` to `true`. Turns `.write()` into a no-op.
diff --git a/node_modules/read/node_modules/mute-stream/mute.js b/node_modules/read/node_modules/mute-stream/mute.js
index 02a9ba50e..f0c3550fe 100644
--- a/node_modules/read/node_modules/mute-stream/mute.js
+++ b/node_modules/read/node_modules/mute-stream/mute.js
@@ -4,11 +4,13 @@ module.exports = MuteStream
// var out = new MuteStream(process.stdout)
// argument auto-pipes
-function MuteStream (dest) {
+function MuteStream (opts) {
Stream.apply(this)
+ opts = opts || {}
this.writable = this.readable = true
this.muted = false
this.on('pipe', this._onpipe)
+ this.replace = opts.replace
}
MuteStream.prototype = Object.create(Stream.prototype)
@@ -75,12 +77,22 @@ MuteStream.prototype.resume = function () {
}
MuteStream.prototype.write = function (c) {
- if (this.muted) return true
+ if (this.muted) {
+ if (!this.replace) return true
+ c = c.toString().replace(/./g, this.replace)
+ }
this.emit('data', c)
}
MuteStream.prototype.end = function (c) {
- if (!this.muted) this.emit('data', c)
+ if (this.muted) {
+ if (c && this.replace) {
+ c = c.toString().replace(/./g, this.replace)
+ } else {
+ c = null
+ }
+ }
+ if (c) this.emit('data', c)
this.emit('end')
}
diff --git a/node_modules/read/node_modules/mute-stream/package.json b/node_modules/read/node_modules/mute-stream/package.json
index 873741a11..ff942b853 100644
--- a/node_modules/read/node_modules/mute-stream/package.json
+++ b/node_modules/read/node_modules/mute-stream/package.json
@@ -1,6 +1,6 @@
{
"name": "mute-stream",
- "version": "0.0.1",
+ "version": "0.0.2",
"main": "mute.js",
"directories": {
"test": "test"
@@ -27,7 +27,10 @@
},
"license": "BSD",
"description": "Bytes go in, but they don't come out (when muted).",
- "readme": "# mute-stream\n\nBytes go in, but they don't come out (when muted).\n\nThis is a basic pass-through stream, but when muted, the bytes are\nsilently dropped, rather than being passed through.\n\n## Usage\n\n```javascript\nvar MuteStream = require('mute-stream')\n\nvar ms = new MuteStream\n\nms.pipe(process.stdout)\nms.write('foo') // writes 'foo' to stdout\nms.mute()\nms.write('bar') // does not write 'bar'\nms.unmute()\nms.write('baz') // writes 'baz' to stdout\n\n// can also be used to mute incoming data\nvar ms = new MuteStream\ninput.pipe(ms)\n\nms.on('data', function (c) {\n console.log('data: ' + c)\n})\n\ninput.emit('data', 'foo') // logs 'foo'\nms.mute()\ninput.emit('data', 'bar') // does not log 'bar'\nms.unmute()\ninput.emit('data', 'baz') // logs 'baz'\n```\n\n## ms.mute()\n\nSet `muted` to `true`. Turns `.write()` into a no-op.\n\n## ms.unmute()\n\nSet `muted` to `false`\n\n## ms.isTTY\n\nTrue if the pipe destination is a TTY, or if the incoming pipe source is\na TTY.\n\n## Other stream methods...\n\nThe other standard readable and writable stream methods are all\navailable. The MuteStream object acts as a facade to its pipe source\nand destination.\n",
- "_id": "mute-stream@0.0.1",
- "_from": "mute-stream@0"
+ "readme": "# mute-stream\n\nBytes go in, but they don't come out (when muted).\n\nThis is a basic pass-through stream, but when muted, the bytes are\nsilently dropped, rather than being passed through.\n\n## Usage\n\n```javascript\nvar MuteStream = require('mute-stream')\n\nvar ms = new MuteStream(options)\n\nms.pipe(process.stdout)\nms.write('foo') // writes 'foo' to stdout\nms.mute()\nms.write('bar') // does not write 'bar'\nms.unmute()\nms.write('baz') // writes 'baz' to stdout\n\n// can also be used to mute incoming data\nvar ms = new MuteStream\ninput.pipe(ms)\n\nms.on('data', function (c) {\n console.log('data: ' + c)\n})\n\ninput.emit('data', 'foo') // logs 'foo'\nms.mute()\ninput.emit('data', 'bar') // does not log 'bar'\nms.unmute()\ninput.emit('data', 'baz') // logs 'baz'\n```\n\n## Options\n\nAll options are optional.\n\n* `replace` Set to a string to replace each character with the\n specified string when muted. (So you can show `****` instead of the\n password, for example.)\n\n## ms.mute()\n\nSet `muted` to `true`. Turns `.write()` into a no-op.\n\n## ms.unmute()\n\nSet `muted` to `false`\n\n## ms.isTTY\n\nTrue if the pipe destination is a TTY, or if the incoming pipe source is\na TTY.\n\n## Other stream methods...\n\nThe other standard readable and writable stream methods are all\navailable. The MuteStream object acts as a facade to its pipe source\nand destination.\n",
+ "_id": "mute-stream@0.0.2",
+ "dist": {
+ "shasum": "75d4466df24a57e80fec806bda88561cd0560d2d"
+ },
+ "_from": "mute-stream@~0.0.2"
}
diff --git a/node_modules/read/node_modules/mute-stream/test/basic.js b/node_modules/read/node_modules/mute-stream/test/basic.js
index ce048ec92..473f82796 100644
--- a/node_modules/read/node_modules/mute-stream/test/basic.js
+++ b/node_modules/read/node_modules/mute-stream/test/basic.js
@@ -133,3 +133,62 @@ tap.test('pause/resume incoming', function (t) {
t.equal(expect.length, 0, 'saw all events')
t.end()
})
+
+tap.test('replace with *', function (t) {
+ var str = new PassThrough
+ var ms = new MS({replace: '*'})
+ str.pipe(ms)
+ var expect = ['foo', '*****', 'bar', '***', 'baz', 'boo', '**', '****']
+
+ ms.on('data', function (c) {
+ t.equal(c, expect.shift())
+ })
+
+ str.write('foo')
+ ms.mute()
+ str.write('12345')
+ ms.unmute()
+ str.write('bar')
+ ms.mute()
+ str.write('baz')
+ ms.unmute()
+ str.write('baz')
+ str.write('boo')
+ ms.mute()
+ str.write('xy')
+ str.write('xyzΩ')
+
+ t.equal(expect.length, 0)
+ t.end()
+})
+
+tap.test('replace with ~YARG~', function (t) {
+ var str = new PassThrough
+ var ms = new MS({replace: '~YARG~'})
+ str.pipe(ms)
+ var expect = ['foo', '~YARG~~YARG~~YARG~~YARG~~YARG~', 'bar',
+ '~YARG~~YARG~~YARG~', 'baz', 'boo', '~YARG~~YARG~',
+ '~YARG~~YARG~~YARG~~YARG~']
+
+ ms.on('data', function (c) {
+ t.equal(c, expect.shift())
+ })
+
+ // also throw some unicode in there, just for good measure.
+ str.write('foo')
+ ms.mute()
+ str.write('ΩΩ')
+ ms.unmute()
+ str.write('bar')
+ ms.mute()
+ str.write('Ω')
+ ms.unmute()
+ str.write('baz')
+ str.write('boo')
+ ms.mute()
+ str.write('Ω')
+ str.write('ΩΩ')
+
+ t.equal(expect.length, 0)
+ t.end()
+})
diff --git a/node_modules/read/package.json b/node_modules/read/package.json
index 256a9e2da..698cf40d9 100644
--- a/node_modules/read/package.json
+++ b/node_modules/read/package.json
@@ -1,9 +1,9 @@
{
"name": "read",
- "version": "1.0.1",
+ "version": "1.0.2",
"main": "lib/read.js",
"dependencies": {
- "mute-stream": "0"
+ "mute-stream": "~0.0.2"
},
"devDependencies": {
"tap": "*"
@@ -25,7 +25,7 @@
"scripts": {
"test": "tap test/*.js"
},
- "readme": "## read\n\nFor reading user input from stdin.\n\nSimilar to the `readline` builtin's `question()` method, but with a\nfew more features.\n\n## USAGE\n\n```javascript\nvar read = require(\"read\")\nread(options, callback)\n```\n\nThe callback gets called with either the user input, or the default\nspecified, or an error, as `callback(error, result, isDefault)`\nnode style.\n\n## OPTIONS\n\nEvery option is optional.\n\n* `prompt` What to write to stdout before reading input.\n* `silent` Don't echo the output as the user types it.\n* `timeout` Number of ms to wait for user input before giving up.\n* `default` The default value if the user enters nothing.\n* `edit` Allow the user to edit the default value.\n* `terminal` Treat the output as a TTY, whether it is or not.\n* `stdin` Readable stream to get input data from. (default `process.stdin`)\n* `stdout` Writeable stream to write prompts to. (default: `process.stdout`)\n\nIf silent is true, and the input is a TTY, then read will set raw\nmode, and read character by character.\n\n## CONTRIBUTING\n\nPatches welcome.\n",
- "_id": "read@1.0.1",
- "_from": "read@latest"
+ "readme": "## read\n\nFor reading user input from stdin.\n\nSimilar to the `readline` builtin's `question()` method, but with a\nfew more features.\n\n## USAGE\n\n```javascript\nvar read = require(\"read\")\nread(options, callback)\n```\n\nThe callback gets called with either the user input, or the default\nspecified, or an error, as `callback(error, result, isDefault)`\nnode style.\n\n## OPTIONS\n\nEvery option is optional.\n\n* `prompt` What to write to stdout before reading input.\n* `silent` Don't echo the output as the user types it.\n* `replace` Replace silenced characters with the supplied character value.\n* `timeout` Number of ms to wait for user input before giving up.\n* `default` The default value if the user enters nothing.\n* `edit` Allow the user to edit the default value.\n* `terminal` Treat the output as a TTY, whether it is or not.\n* `stdin` Readable stream to get input data from. (default `process.stdin`)\n* `stdout` Writeable stream to write prompts to. (default: `process.stdout`)\n\nIf silent is true, and the input is a TTY, then read will set raw\nmode, and read character by character.\n\n## CONTRIBUTING\n\nPatches welcome.\n",
+ "_id": "read@1.0.2",
+ "_from": "read@~1"
}