improve backward compat with node <=0.6.0.
This commit is contained in:
parent
29f70f11f9
commit
bdb3f098ca
|
@ -157,30 +157,34 @@ helpers.__defineGetter__('Element', function() {
|
|||
return helpers._element;
|
||||
});
|
||||
|
||||
// NOTE: Leave these here for now if we
|
||||
// want to potentially support node <=v0.6.0.
|
||||
|
||||
helpers.isTTY = function(stream) {
|
||||
if (stream.setRawMode || stream.isTTY) {
|
||||
if (stream.isTTY) {
|
||||
return true;
|
||||
}
|
||||
if (stream === process.stdin) {
|
||||
return true;
|
||||
if (stream.fd != null) {
|
||||
return require('tty').isatty(stream.fd);
|
||||
}
|
||||
// if (stream.fd != null) {
|
||||
// return require('tty').isatty(stream.fd);
|
||||
// }
|
||||
return false;
|
||||
};
|
||||
|
||||
helpers.hasRaw = function(stream, value) {
|
||||
return !!stream.setRawMode
|
||||
|| (stream === process.stdin)
|
||||
|| !!(stream._handle && stream._handle.setRawMode && stream.readable);
|
||||
};
|
||||
|
||||
helpers.setRawMode = function(stream, value) {
|
||||
if (stream.setRawMode) {
|
||||
return stream.setRawMode(value);
|
||||
}
|
||||
if (stream === process.stdin) {
|
||||
helpers._isRaw = value;
|
||||
stream._blessedRaw = value;
|
||||
return require('tty').setRawMode(value);
|
||||
}
|
||||
if (stream._handle && stream._handle.setRawMode && stream.readable) {
|
||||
stream._blessedRaw = value;
|
||||
return stream._handle.setRawMode(value);
|
||||
}
|
||||
throw new Error('Could not set raw mode.');
|
||||
};
|
||||
|
||||
|
@ -188,8 +192,5 @@ helpers.isRaw = function(stream) {
|
|||
if (stream.isRaw != null) {
|
||||
return stream.isRaw;
|
||||
}
|
||||
if (stream === process.stdin) {
|
||||
return !!helpers._isRaw;
|
||||
}
|
||||
throw new Error('Could not check raw mode.');
|
||||
return !!stream._blessedRaw;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue