diff options
author | isaacs <i@izs.me> | 2012-08-17 05:04:54 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-08-17 05:04:54 +0400 |
commit | ef851754559f842c79042c69f996f2d85477bb20 (patch) | |
tree | 5077d5c90089d9c0c62eb34088663f27175666ec /node_modules/read | |
parent | b462864b15341e01dc13f0da62461f9b490235ef (diff) |
read@1.0.4
Diffstat (limited to 'node_modules/read')
-rw-r--r-- | node_modules/read/README.md | 15 | ||||
-rw-r--r-- | node_modules/read/lib/read.js | 15 | ||||
-rw-r--r-- | node_modules/read/node_modules/mute-stream/mute.js | 15 | ||||
-rw-r--r-- | node_modules/read/node_modules/mute-stream/package.json | 7 | ||||
-rw-r--r-- | node_modules/read/node_modules/mute-stream/test/basic.js | 12 | ||||
-rw-r--r-- | node_modules/read/package.json | 8 | ||||
-rw-r--r-- | node_modules/read/test/basic.js | 7 | ||||
-rw-r--r-- | node_modules/read/test/defaults.js | 7 | ||||
-rw-r--r-- | node_modules/read/test/many.js | 7 |
9 files changed, 80 insertions, 13 deletions
diff --git a/node_modules/read/README.md b/node_modules/read/README.md index 01aa8e76b..2edefdf47 100644 --- a/node_modules/read/README.md +++ b/node_modules/read/README.md @@ -33,6 +33,21 @@ Every option is optional. If silent is true, and the input is a TTY, then read will set raw mode, and read character by character. +## COMPATIBILITY + +This module works sort of with node 0.6. It does not work with node +versions less than 0.6. It is best on node 0.8. + +On node version 0.6, it will remove all listeners on the input +stream's `data` and `keypress` events, because the readline module did +not fully clean up after itself in that version of node, and did not +make it possible to clean up after it in a way that has no potential +for side effects. + +Additionally, some of the readline options (like `terminal`) will not +function in versions of node before 0.8, because they were not +implemented in the builtin readline module. + ## CONTRIBUTING Patches welcome. diff --git a/node_modules/read/lib/read.js b/node_modules/read/lib/read.js index 4b0e303f6..4b8a422d9 100644 --- a/node_modules/read/lib/read.js +++ b/node_modules/read/lib/read.js @@ -23,7 +23,13 @@ function read (opts, cb) { var def = opts.default || '' var terminal = !!(opts.terminal || output.isTTY) var rlOpts = { input: input, output: output, terminal: terminal } - var rl = readline.createInterface(rlOpts) + + 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 @@ -69,6 +75,13 @@ function read (opts, cb) { function done () { called = true rl.close() + + if (process.version.match(/^v0\.6/)) { + rl.input.removeAllListeners('data') + rl.input.removeAllListeners('keypress') + rl.input.pause() + } + clearTimeout(timer) output.mute() output.end() diff --git a/node_modules/read/node_modules/mute-stream/mute.js b/node_modules/read/node_modules/mute-stream/mute.js index f0c3550fe..7746618a1 100644 --- a/node_modules/read/node_modules/mute-stream/mute.js +++ b/node_modules/read/node_modules/mute-stream/mute.js @@ -63,6 +63,21 @@ function setIsTTY (isTTY) { }) } +Object.defineProperty(MuteStream.prototype, 'rows', { + get: function () { + return( this._dest ? this._dest.rows + : this._src ? this._src.rows + : undefined ) + }, enumerable: true, configurable: true }) + +Object.defineProperty(MuteStream.prototype, 'columns', { + get: function () { + return( this._dest ? this._dest.columns + : this._src ? this._src.columns + : undefined ) + }, enumerable: true, configurable: true }) + + MuteStream.prototype.pipe = function (dest) { this._dest = dest return Stream.prototype.pipe.call(this, dest) diff --git a/node_modules/read/node_modules/mute-stream/package.json b/node_modules/read/node_modules/mute-stream/package.json index ff942b853..629b5be67 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.2", + "version": "0.0.3", "main": "mute.js", "directories": { "test": "test" @@ -28,9 +28,6 @@ "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.2", - "dist": { - "shasum": "75d4466df24a57e80fec806bda88561cd0560d2d" - }, + "_id": "mute-stream@0.0.3", "_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 473f82796..2d1f6aed3 100644 --- a/node_modules/read/node_modules/mute-stream/test/basic.js +++ b/node_modules/read/node_modules/mute-stream/test/basic.js @@ -89,17 +89,29 @@ tap.test('outgoing', function (t) { tap.test('isTTY', function (t) { var str = new PassThrough str.isTTY = true + str.columns=80 + str.rows=24 var ms = new MS t.equal(ms.isTTY, false) + t.equal(ms.columns, undefined) + t.equal(ms.rows, undefined) ms.pipe(str) t.equal(ms.isTTY, true) + t.equal(ms.columns, 80) + t.equal(ms.rows, 24) str.isTTY = false t.equal(ms.isTTY, false) + t.equal(ms.columns, 80) + t.equal(ms.rows, 24) str.isTTY = true t.equal(ms.isTTY, true) + t.equal(ms.columns, 80) + t.equal(ms.rows, 24) ms.isTTY = false t.equal(ms.isTTY, false) + t.equal(ms.columns, 80) + t.equal(ms.rows, 24) ms = new MS t.equal(ms.isTTY, false) diff --git a/node_modules/read/package.json b/node_modules/read/package.json index 79e5b7ce2..f76034e86 100644 --- a/node_modules/read/package.json +++ b/node_modules/read/package.json @@ -1,6 +1,6 @@ { "name": "read", - "version": "1.0.3", + "version": "1.0.4", "main": "lib/read.js", "dependencies": { "mute-stream": "~0.0.2" @@ -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* `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.3", - "_from": "read@~1" + "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" } diff --git a/node_modules/read/test/basic.js b/node_modules/read/test/basic.js index c90c41036..f5324b4aa 100644 --- a/node_modules/read/test/basic.js +++ b/node_modules/read/test/basic.js @@ -5,6 +5,11 @@ if (process.argv[2] === 'child') { return child() } +var CLOSE = 'close' +if (process.version.match(/^v0\.6/)) { + CLOSE = 'exit' +} + var spawn = require('child_process').spawn tap.test('basic', function (t) { @@ -31,7 +36,7 @@ tap.test('basic', function (t) { console.error('result %j', c.toString()) }) - child.on('close', function () { + child.on(CLOSE, function () { result = JSON.parse(result) t.same(result, {"user":"a user","pass":"a password","verify":"a password","passMatch":true}) t.equal(output, 'Username: (test-user) Password: (<default hidden>) Password again: (<default hidden>) ') diff --git a/node_modules/read/test/defaults.js b/node_modules/read/test/defaults.js index 6f7644d2a..f3335ac82 100644 --- a/node_modules/read/test/defaults.js +++ b/node_modules/read/test/defaults.js @@ -5,6 +5,11 @@ if (process.argv[2] === 'child') { return child() } +var CLOSE = 'close' +if (process.version.match(/^v0\.6/)) { + CLOSE = 'exit' +} + var spawn = require('child_process').spawn tap.test('defaults', function (t) { @@ -31,7 +36,7 @@ tap.test('defaults', function (t) { console.error('result %j', c.toString()) }) - child.on('close', function () { + child.on(CLOSE, function () { result = JSON.parse(result) t.same(result, {"user":"test-user","pass":"test-pass","verify":"test-pass","passMatch":true}) t.equal(output, 'Username: (test-user) Password: (<default hidden>) Password again: (<default hidden>) ') diff --git a/node_modules/read/test/many.js b/node_modules/read/test/many.js index 0d32dae8a..2aaa586e4 100644 --- a/node_modules/read/test/many.js +++ b/node_modules/read/test/many.js @@ -1,6 +1,11 @@ var tap = require('tap') var read = require('../lib/read.js') +var CLOSE = 'close' +if (process.version.match(/^v0\.6/)) { + CLOSE = 'exit' +} + if (process.argv[2] === 'child') { return child() } @@ -68,7 +73,7 @@ tap.test('many reads', function (t) { output += c console.error('' + c) }) - child.on('close', function (c) { + child.on(CLOSE, function (c) { t.equal(output, expect) t.equal(n, 19) t.end() |