Comparing version 0.0.1 to 0.0.2
@@ -6,8 +6,10 @@ var read = require("../lib/read.js") | ||
read({prompt: "Enter 4 characters: ", num: 4 }, function (er, four) { | ||
console.error(user + ":" + pass + " " + JSON.stringify(four)) | ||
console.error("If the program doesn't end right now,\n" | ||
+"then you may be experiencing this bug:\n" | ||
+"https://github.com/joyent/node/issues/2257") | ||
read({prompt: "Password again: ", default: "test-pass", silent: true }, function (er, pass2) { | ||
console.error(user + ":" + pass + " (" + pass2 + ") " + JSON.stringify(four) + (pass === pass2)) | ||
console.error("If the program doesn't end right now,\n" | ||
+"then you may be experiencing this bug:\n" | ||
+"https://github.com/joyent/node/issues/2257") | ||
}) | ||
}) | ||
}) | ||
}) |
@@ -8,2 +8,10 @@ | ||
function raw (mode) { | ||
try { | ||
process.stdin.setRawMode(mode) | ||
} catch (e) { | ||
tty.setRawMode(mode) | ||
} | ||
} | ||
function read (opts, cb) { | ||
@@ -29,3 +37,3 @@ if (!cb) cb = opts, opts = {} | ||
var t = setTimeout(function () { | ||
tty.setRawMode(false) | ||
raw(false) | ||
process.stdout.write("\n") | ||
@@ -114,3 +122,3 @@ if (def) done(null, def) | ||
tty.setRawMode(true) | ||
raw(true) | ||
stdin.resume() | ||
@@ -128,3 +136,3 @@ stdin.on("error", cb) | ||
case delim: | ||
tty.setRawMode(false) | ||
raw(false) | ||
stdin.removeListener("data", D) | ||
@@ -138,3 +146,3 @@ stdin.removeListener("error", cb) | ||
case "\u0003": case "\0": // ^C or other signal abort | ||
tty.setRawMode(false) | ||
raw(false) | ||
stdin.removeListener("data", D) | ||
@@ -141,0 +149,0 @@ stdin.removeListener("error", cb) |
{ | ||
"name": "read", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "lib/read.js", | ||
@@ -15,3 +15,4 @@ "dependencies": {}, | ||
"url": "git://github.com/isaacs/read.git" | ||
} | ||
}, | ||
"license":"BSD" | ||
} |
@@ -23,2 +23,3 @@ For reading user input from stdin. | ||
* `timeout` Number of ms to wait for user input before giving up. | ||
* `default` The default value if the user enters nothing. | ||
@@ -35,1 +36,10 @@ If silent is true, or num is set, or delim is something other than | ||
Patches welcome. | ||
## BUGS | ||
In node 0.6.0 through 0.6.5, you must explicitly call | ||
`process.stdin.destroy()` or `process.exit()` when you know that your | ||
program is done reading, or else it will keep the event loop running | ||
forever. | ||
See: <https://github.com/joyent/node/issues/2257> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
7552
5
0
147
44
1