Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

read@1.0.4

  • Loading branch information...
commit ef851754559f842c79042c69f996f2d85477bb20 1 parent b462864
@isaacs isaacs authored
View
15 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.
View
15 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()
View
15 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)
View
7 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"
}
View
12 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)
View
8 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"
}
View
7 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>) ')
View
7 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>) ')
View
7 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()

0 comments on commit ef85175

Please sign in to comment.
Something went wrong with that request. Please try again.