c9-core/plugins/c9.fs/proc2pty.js

27 wiersze
754 B
JavaScript
Czysty Zwykły widok Historia

2015-03-31 22:17:41 +00:00
define(function(require, exports, module) {
var EventEmitter = require("events").EventEmitter;
module.exports = function(process){
var pty = new EventEmitter();
pty.write = function(data){
2015-04-28 00:09:16 +00:00
process.stdin.write(data.replace(/\r/g, "\n"));
2015-03-31 22:17:41 +00:00
};
pty.resize = function(){};
pty.destroy =
pty.end = function(){
process.kill();
};
process.stdout.on("data", function(chunk){
pty.emit("data", chunk);
});
process.stderr.on("data", function(chunk){
pty.emit("data", chunk);
});
process.on("exit", function(code){
pty.emit("exit", code);
});
return pty;
2015-04-28 00:09:16 +00:00
};
2015-03-31 22:17:41 +00:00
});