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

27 wiersze
761 B
JavaScript
Czysty Zwykły widok Historia

2016-06-26 11:53:19 +00:00
define(function(require, exports, module) {
var EventEmitter = require("events").EventEmitter;
2017-01-30 11:32:54 +00:00
module.exports = function(process) {
2016-06-26 11:53:19 +00:00
var pty = new EventEmitter();
2017-01-30 11:32:54 +00:00
pty.write = function(data) {
2016-06-26 11:53:19 +00:00
process.stdin.write(data.replace(/\r/g, "\n"));
};
2017-01-30 11:32:54 +00:00
pty.resize = function() {};
2016-06-26 11:53:19 +00:00
pty.destroy =
2017-01-30 11:32:54 +00:00
pty.end = function() {
2016-06-26 11:53:19 +00:00
process.kill();
};
2017-01-30 11:32:54 +00:00
process.stdout.on("data", function(chunk) {
2016-06-26 11:53:19 +00:00
pty.emit("data", chunk);
});
2017-01-30 11:32:54 +00:00
process.stderr.on("data", function(chunk) {
2016-06-26 11:53:19 +00:00
pty.emit("data", chunk);
});
2017-01-30 11:32:54 +00:00
process.on("exit", function(code) {
2016-06-26 11:53:19 +00:00
pty.emit("exit", code);
});
return pty;
};
});