Skip to content

Loading…

tty.setRawMode is replaced by process.stdin.setRawMode #1

Closed
wants to merge 1 commit into from

3 participants

@samtsai

in the latest version of node. - similar to pull request in node-charm

@samtsai samtsai tty.setRawMode is replaced by process.stdin.setRawMode in the latest …
…version of node. - similar to pull request in node-charm
fc063fd
@jswartwood

This would obviously break node < 0.8; what is the typical strategy for not breaking with old versions of node? I assume the package.json should also be updated to specify "engine": ">= 0.8".

@jswartwood

This can be closed as of 06c5eaa

@samtsai samtsai closed this
@jaymedavis

Did something break this? This does not appear to work in version 0.8.8.

  process.stdin.setRawMode(true);
                ^

TypeError: Object # has no method 'setRawMode'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 26, 2012
  1. @samtsai

    tty.setRawMode is replaced by process.stdin.setRawMode in the latest …

    samtsai committed
    …version of node. - similar to pull request in node-charm
Showing with 10 additions and 12 deletions.
  1. +10 −12 index.js
View
22 index.js
@@ -1,5 +1,3 @@
-var tty = require('tty');
-
module.exports = function () {
var opts = {
seperator : '*',
@@ -7,7 +5,7 @@ module.exports = function () {
out : process.stdout,
cb : function () {}
};
-
+
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
switch (typeof arg) {
@@ -27,29 +25,29 @@ module.exports = function () {
break;
}
}
-
+
var stream = {
in : opts.in,
out : opts.out
};
-
+
var sep = opts.seperator;
var cb = opts.cb;
-
+
if (stream.in === process.stdin) {
- tty.setRawMode(true);
+ process.stdin.setRawMode(true);
}
-
+
var line = '';
stream.in.on('data', function ondata (buf) {
function finish () {
if (stream.in === process.stdin) {
- tty.setRawMode(false);
+ process.stdin.setRawMode(false);
}
if (stream.in.pause) stream.in.pause();
stream.in.removeListener('data', ondata);
}
-
+
if (buf.length === 1) {
if (buf[0] === 3) {
finish();
@@ -68,7 +66,7 @@ module.exports = function () {
return;
}
}
-
+
for (var i = 0; i < buf.length; i++) {
var c = String.fromCharCode(buf[i]);
if (c === '\n' || c === '\r') {
@@ -83,6 +81,6 @@ module.exports = function () {
}
}
});
-
+
if (stream.in.resume) stream.in.resume();
};
Something went wrong with that request. Please try again.