0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
nodejs/lib/tty.js
Ryan Dahl a0e9a510b0 Introduce require('tty')
You may need to reconfigure after this commit due to the new library.
2010-12-02 18:06:43 -08:00

29 lines
520 B
JavaScript

var spawn = require('child_process').spawn;
var binding = process.binding('stdio');
exports.isatty = binding.isatty;
exports.setRawMode = binding.setRawMode;
exports.getColumns = binding.getColumns;
exports.open = function(path, args) {
var fds = binding.openpty();
var masterFD = fds[1];
var slaveFD = fds[0];
var env = { TERM: 'vt100' };
for (var k in process.env) {
env[k] = process.env[k];
}
child = spawn(path, args, env, [masterFD, masterFD, masterFD]);
return [slaveFD, child];
};