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>2013-07-24 07:29:58 +0400
committerisaacs <i@izs.me>2013-07-24 07:29:58 +0400
commite323b8ffaaaf9b55054ad2150f66d8f13f5ad147 (patch)
treeed9f82015eafc5a9e736e25cfff0a3c59a2173e0 /node_modules/read
parent57ec07ac9f7107c3796484cb163d3a0a0635c084 (diff)
read@1.0.5
Diffstat (limited to 'node_modules/read')
-rw-r--r--node_modules/read/README.md4
-rw-r--r--node_modules/read/lib/read.js27
-rw-r--r--node_modules/read/node_modules/mute-stream/README.md6
-rw-r--r--node_modules/read/node_modules/mute-stream/mute.js19
-rw-r--r--node_modules/read/node_modules/mute-stream/package.json12
-rw-r--r--node_modules/read/node_modules/mute-stream/test/basic.js1
-rw-r--r--node_modules/read/package.json14
-rw-r--r--node_modules/read/rs.js4
-rw-r--r--node_modules/read/test/basic.js2
-rw-r--r--node_modules/read/test/defaults.js2
-rw-r--r--node_modules/read/test/many.js2
11 files changed, 68 insertions, 25 deletions
diff --git a/node_modules/read/README.md b/node_modules/read/README.md
index 2edefdf47..5967fad11 100644
--- a/node_modules/read/README.md
+++ b/node_modules/read/README.md
@@ -27,8 +27,8 @@ Every option is optional.
* `default` The default value if the user enters nothing.
* `edit` Allow the user to edit the default value.
* `terminal` Treat the output as a TTY, whether it is or not.
-* `stdin` Readable stream to get input data from. (default `process.stdin`)
-* `stdout` Writeable stream to write prompts to. (default: `process.stdout`)
+* `input` Readable stream to get input data from. (default `process.stdin`)
+* `output` Writeable stream to write prompts to. (default: `process.stdout`)
If silent is true, and the input is a TTY, then read will set raw
mode, and read character by character.
diff --git a/node_modules/read/lib/read.js b/node_modules/read/lib/read.js
index 4b8a422d9..a93d1b3b5 100644
--- a/node_modules/read/lib/read.js
+++ b/node_modules/read/lib/read.js
@@ -17,24 +17,12 @@ function read (opts, cb) {
var input = opts.input || process.stdin
var output = opts.output || process.stdout
- var m = new Mute({ replace: opts.replace })
- m.pipe(output, {end: false})
- output = m
- var def = opts.default || ''
- var terminal = !!(opts.terminal || output.isTTY)
- var rlOpts = { input: input, output: output, terminal: terminal }
-
- if (process.version.match(/^v0\.6/)) {
- var rl = readline.createInterface(rlOpts.input, rlOpts.output)
- } else {
- var rl = readline.createInterface(rlOpts)
- }
-
var prompt = (opts.prompt || '').trim() + ' '
var silent = opts.silent
var editDef = false
var timeout = opts.timeout
+ var def = opts.default || ''
if (def) {
if (silent) {
prompt += '(<default hidden>) '
@@ -44,6 +32,19 @@ function read (opts, cb) {
prompt += '(' + def + ') '
}
}
+ var terminal = !!(opts.terminal || output.isTTY)
+
+ var m = new Mute({ replace: opts.replace, prompt: prompt })
+ m.pipe(output, {end: false})
+ output = m
+ var rlOpts = { input: input, output: output, terminal: terminal }
+
+ if (process.version.match(/^v0\.6/)) {
+ var rl = readline.createInterface(rlOpts.input, rlOpts.output)
+ } else {
+ var rl = readline.createInterface(rlOpts)
+ }
+
output.unmute()
rl.setPrompt(prompt)
diff --git a/node_modules/read/node_modules/mute-stream/README.md b/node_modules/read/node_modules/mute-stream/README.md
index 91b45c40c..8ab1238e4 100644
--- a/node_modules/read/node_modules/mute-stream/README.md
+++ b/node_modules/read/node_modules/mute-stream/README.md
@@ -42,6 +42,12 @@ All options are optional.
specified string when muted. (So you can show `****` instead of the
password, for example.)
+* `prompt` If you are using a replacement char, and also using a
+ prompt with a readline stream (as for a `Password: *****` input),
+ then specify what the prompt is so that backspace will work
+ properly. Otherwise, pressing backspace will overwrite the prompt
+ with the replacement character, which is weird.
+
## 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 7746618a1..42eac31e1 100644
--- a/node_modules/read/node_modules/mute-stream/mute.js
+++ b/node_modules/read/node_modules/mute-stream/mute.js
@@ -11,6 +11,12 @@ function MuteStream (opts) {
this.muted = false
this.on('pipe', this._onpipe)
this.replace = opts.replace
+
+ // For readline-type situations
+ // This much at the start of a line being redrawn after a ctrl char
+ // is seen (such as backspace) won't be redrawn as the replacement
+ this._prompt = opts.prompt || null
+ this._hadControl = false
}
MuteStream.prototype = Object.create(Stream.prototype)
@@ -94,7 +100,18 @@ MuteStream.prototype.resume = function () {
MuteStream.prototype.write = function (c) {
if (this.muted) {
if (!this.replace) return true
- c = c.toString().replace(/./g, this.replace)
+ if (c.match(/^\u001b/)) {
+ this._hadControl = true
+ return this.emit('data', c)
+ } else {
+ if (this._prompt && this._hadControl &&
+ c.indexOf(this._prompt) === 0) {
+ this._hadControl = false
+ this.emit('data', this._prompt)
+ c = c.substr(this._prompt.length)
+ }
+ c = c.toString().replace(/./g, this.replace)
+ }
}
this.emit('data', c)
}
diff --git a/node_modules/read/node_modules/mute-stream/package.json b/node_modules/read/node_modules/mute-stream/package.json
index 629b5be67..5e699801f 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.3",
+ "version": "0.0.4",
"main": "mute.js",
"directories": {
"test": "test"
@@ -27,7 +27,11 @@
},
"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(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.3",
- "_from": "mute-stream@~0.0.2"
+ "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* `prompt` If you are using a replacement char, and also using a\n prompt with a readline stream (as for a `Password: *****` input),\n then specify what the prompt is so that backspace will work\n properly. Otherwise, pressing backspace will overwrite the prompt\n with the replacement character, which is weird.\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",
+ "readmeFilename": "README.md",
+ "bugs": {
+ "url": "https://github.com/isaacs/mute-stream/issues"
+ },
+ "_id": "mute-stream@0.0.4",
+ "_from": "mute-stream@~0.0.4"
}
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 2d1f6aed3..41f9e10c3 100644
--- a/node_modules/read/node_modules/mute-stream/test/basic.js
+++ b/node_modules/read/node_modules/mute-stream/test/basic.js
@@ -19,6 +19,7 @@ PassThrough.prototype = Object.create(Stream.prototype, {
write: {
value: function (c) {
this.emit('data', c)
+ return true
}
},
end: {
diff --git a/node_modules/read/package.json b/node_modules/read/package.json
index f76034e86..c5be57230 100644
--- a/node_modules/read/package.json
+++ b/node_modules/read/package.json
@@ -1,9 +1,9 @@
{
"name": "read",
- "version": "1.0.4",
+ "version": "1.0.5",
"main": "lib/read.js",
"dependencies": {
- "mute-stream": "~0.0.2"
+ "mute-stream": "~0.0.4"
},
"devDependencies": {
"tap": "*"
@@ -25,7 +25,11 @@
"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* `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## COMPATIBILITY\n\nThis module works sort of with node 0.6. It does not work with node\nversions less than 0.6. It is best on node 0.8.\n\nOn node version 0.6, it will remove all listeners on the input\nstream's `data` and `keypress` events, because the readline module did\nnot fully clean up after itself in that version of node, and did not\nmake it possible to clean up after it in a way that has no potential\nfor side effects.\n\nAdditionally, some of the readline options (like `terminal`) will not\nfunction in versions of node before 0.8, because they were not\nimplemented in the builtin readline module.\n\n## CONTRIBUTING\n\nPatches welcome.\n",
- "_id": "read@1.0.4",
- "_from": "read@~1.0.3"
+ "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* `input` Readable stream to get input data from. (default `process.stdin`)\n* `output` 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## COMPATIBILITY\n\nThis module works sort of with node 0.6. It does not work with node\nversions less than 0.6. It is best on node 0.8.\n\nOn node version 0.6, it will remove all listeners on the input\nstream's `data` and `keypress` events, because the readline module did\nnot fully clean up after itself in that version of node, and did not\nmake it possible to clean up after it in a way that has no potential\nfor side effects.\n\nAdditionally, some of the readline options (like `terminal`) will not\nfunction in versions of node before 0.8, because they were not\nimplemented in the builtin readline module.\n\n## CONTRIBUTING\n\nPatches welcome.\n",
+ "readmeFilename": "README.md",
+ "bugs": {
+ "url": "https://github.com/isaacs/read/issues"
+ },
+ "_id": "read@1.0.5",
+ "_from": "read@latest"
}
diff --git a/node_modules/read/rs.js b/node_modules/read/rs.js
new file mode 100644
index 000000000..d9f7f48dd
--- /dev/null
+++ b/node_modules/read/rs.js
@@ -0,0 +1,4 @@
+var read = require('read');
+read({ silent: true, prompt: 'stars: ' }, function(er, data) {
+ console.log(er, data)
+})
diff --git a/node_modules/read/test/basic.js b/node_modules/read/test/basic.js
index f5324b4aa..f0926f3f2 100644
--- a/node_modules/read/test/basic.js
+++ b/node_modules/read/test/basic.js
@@ -52,6 +52,8 @@ function child () {
pass: pass,
verify: pass2,
passMatch: (pass === pass2)}))
+ if (process.stdin.unref)
+ process.stdin.unref()
})
})
})
diff --git a/node_modules/read/test/defaults.js b/node_modules/read/test/defaults.js
index f3335ac82..e3d2ac710 100644
--- a/node_modules/read/test/defaults.js
+++ b/node_modules/read/test/defaults.js
@@ -52,6 +52,8 @@ function child () {
pass: pass,
verify: pass2,
passMatch: (pass === pass2)}))
+ if (process.stdin.unref)
+ process.stdin.unref()
})
})
})
diff --git a/node_modules/read/test/many.js b/node_modules/read/test/many.js
index 2aaa586e4..6a2f87b86 100644
--- a/node_modules/read/test/many.js
+++ b/node_modules/read/test/many.js
@@ -32,6 +32,8 @@ function child () {
read({prompt:'18'}, function (er, r18) {if (er) throw er
console.log(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
r11, r12, r13, r14, r15, r16, r17, r18)
+ if (process.stdin.unref)
+ process.stdin.unref()
})})})})})})})})})})})})})})})})})})
}