Merge pull request +8111 from c9/fix/meteor

Fix debugging meteor applications
pull/152/head
Ruben Daniels 2015-09-13 11:57:03 -07:00
commit 476d6e9ff8
7 zmienionych plików z 214 dodań i 9 usunięć

Wyświetl plik

@ -196,6 +196,8 @@ function LineWidgets(session) {
this.session.lineWidgets[w.row] = w;
w.session = this.session;
var renderer = this.editor.renderer;
if (w.html && !w.el) {
w.el = dom.createElement("div");
@ -239,6 +241,7 @@ function LineWidgets(session) {
this.removeLineWidget = function(w) {
w._inDocument = false;
w.session = null;
if (w.el && w.el.parentNode)
w.el.parentNode.removeChild(w.el);
if (w.editor && w.editor.destroy) try {
@ -269,7 +272,7 @@ function LineWidgets(session) {
var w = lineWidgets && lineWidgets[row];
var list = [];
while (w) {
list.push(w)
list.push(w);
w = w.$oldWidget;
}
return list;
@ -289,6 +292,7 @@ function LineWidgets(session) {
for (var i = 0; i < changedWidgets.length; i++) {
var w = changedWidgets[i];
if (!w || !w.el) continue;
if (w.session != this.session) continue;
if (!w._inDocument) {
w._inDocument = true;
renderer.container.appendChild(w.el);

28
node_modules/vfs-local/localfs.js wygenerowano vendored
Wyświetl plik

@ -1955,7 +1955,10 @@ module.exports = function setup(fsOptions) {
}
}
function PtyStream(pty, isOutput){
function PtyStream(pty, isOutput, old){
if (old) {
return old.attachTo(pty, isOutput);
}
var exited = false;
var killed = false;
@ -1975,6 +1978,18 @@ module.exports = function setup(fsOptions) {
pty.kill = function() {};
}
this.attachTo = function(newPty) {
pty = newPty;
exited = false;
killed = false;
this.readable = true;
this.writable = true;
Object.keys(events).forEach(forwardEvent);
return this;
}
this.killtree =
this.kill = isOutput ? function(signal){
// We dont want to really kill, just stop the process
@ -1988,7 +2003,7 @@ module.exports = function setup(fsOptions) {
emit("kill");
});
}
pty.suspended = true;
return;
}
@ -2022,7 +2037,7 @@ module.exports = function setup(fsOptions) {
var events = {};
function forwardEvent(name){
events[name] = [];
events[name] = events[name] || [];
if (isOutput && (name == "exit" || name == "close" || name == "end")) {
if (name != "exit") return;
@ -2102,7 +2117,7 @@ module.exports = function setup(fsOptions) {
if (session) {
if (session.wait)
session.wait.push(callback);
else
else if (session.pty && !session.pty.suspended)
callback(null, { pty: session.pty });
}
else
@ -2124,8 +2139,9 @@ module.exports = function setup(fsOptions) {
var args = ["-l", "-i"];
var name = options.session || getSessionId();
var session = { wait: [] };
var session = sessions[name] || {};
sessions[name] = session;
if (!session.wait) session.wait = [];
if (options.idle)
options.command = "echo '\033[2J\033[1;1H[Idle]'";
@ -2167,7 +2183,7 @@ module.exports = function setup(fsOptions) {
if (err) return callback(err);
session.pty = meta.pty =
new PtyStream(meta.pty, options.output);
new PtyStream(meta.pty, options.output, session.pty);
var wait = session.wait;
delete session.wait;

Wyświetl plik

@ -71,7 +71,7 @@
"c9.ide.find": "#35379124ca",
"c9.ide.find.infiles": "#c132ad243c",
"c9.ide.find.replace": "#44772dd796",
"c9.ide.run.debug": "#2bc3f31089",
"c9.ide.run.debug": "#e38e16e120",
"c9.automate": "#47e2c429c9",
"c9.ide.ace.emmet": "#6dc4585e02",
"c9.ide.ace.gotoline": "#a8ff07c8f4",
@ -102,7 +102,7 @@
"c9.ide.recentfiles": "#7c099abf40",
"c9.ide.remote": "#301d2ab519",
"c9.ide.processlist": "#bc11818bb5",
"c9.ide.run": "#c53178c339",
"c9.ide.run": "#05c0054752",
"c9.ide.run.build": "#0598fff697",
"c9.ide.run.debug.xdebug": "#61dcbd0180",
"c9.ide.save": "#e00549cb0f",

Wyświetl plik

@ -0,0 +1,20 @@
// This file overrides the built-in Node.js runner
// For more information see http://docs.c9.io:8080/#!/api/run-method-run
{
"cmd": [
"node",
"debug.js",
"1588",
"$file",
"$args"
],
"debugger": "v8",
"debugport": 1588,
"debuggerConfig": {
"pathMap": [],
"ignoreBreak": {
"x": 1
}
},
"selector": "source.js"
}

Wyświetl plik

@ -0,0 +1,154 @@
/**
* in meteor runner restarts debug process after each save.
* this emulates same sequence of events without all of the complexity of meteor
*
* add the following run config, run test.js file, write timeout value in output window
* and press enter to restart test.js after a timeout
*
* "run": {
* "@path": "/.c9/runners",
* "configs": {
* "@inited": "true",
* "json()": {
* "mock-meteor": {
* "command": "test.js",
* "debug": true,
* "name": "mock-meteor",
* "runner": "Node.js.test"
* }
* }
* }
* },
**/
var net = require("net");
var spawn = require("child_process").spawn;
var argv = process.argv;
var port = argv[2];
var debugPort = 5758;
var p, interceptServer;
var outConnection = [];
var inConnection = [];
var RETRY_INTERVAL = 500;
function start() {
console.log(argv[0], ["--debug-brk=" + debugPort].concat(argv.slice(3)));
p = spawn(argv[0], ["--debug-brk=" + debugPort].concat(argv.slice(3)), {});
p.stdout.on("data", function(e) {
process.stdout.write(e);
});
p.stderr.on("data", function(e) {
process.stderr.write(e);
});
function tryConnect(port, retries, callback) {
console.log("tryConnect", retries, port);
if (!retries)
return callback(new Error("Cannot connect to port " + port));
var connection = net.connect(port, "localhost");
connection.on("connect", function() {
console.log("netproxy connected to debugger");
connection.removeListener("error", onError);
callback(null, connection);
});
connection.addListener("error", onError);
function onError(e) {
if (e.code !== "ECONNREFUSED")
return callback(e);
setTimeout(function() {
tryConnect(port, retries - 1, callback);
}, RETRY_INTERVAL);
}
}
tryConnect(debugPort, 100, function(e, debugConnection) {
console.log("-----------------------------");
debugConnection.on("data", function(data) {
console.log(data + "" + (!outConnection.write ? "<buffer>" : ""));
if (outConnection.write)
outConnection.write(data);
else
outConnection.push(data);
});
inConnection = debugConnection;
debugConnection.once("data", startServer);
debugConnection.on("error", function(e) {
console.log(e);
});
});
outConnection = outConnection || [];
inConnection = [];
function startServer() {
console.log("start-server")
interceptServer = net.createServer(function(socket) {
console.log(socket)
outConnection.forEach(function(e) {socket.write(e)});
outConnection = socket;
socket.on("data", function(buffer) {
inConnection.write(buffer);
});
socket.on("error", function(e) {
console.log(e);
})
socket.on("end", function(e) {
outConnection = null
});
}).on("error", function(e) {
interceptServer = null;
console.error(e);
}).listen(port);
}
}
function stop() {
if (start.timer) clearTimeout(start.timer);
p && p.kill();
interceptServer && interceptServer.close();
inConnection.end && inConnection.end();
// outConnection.end && outConnection.end();
}
process.stdin.resume();
process.stdin.setRawMode(true);
process.stdin.setEncoding("utf8");
process.on('SIGINT', function() {
console.log('Got SIGINT. Press Control-D to exit.');
});
process.on("SIGINT", function() {
console.log(process.argv);
});
var buffer = "";
process.stdin.on("data", function(s) {
process.stdout.write(s);
buffer += s;
var i = buffer.search(/\s/);
if (i == -1) return;
if (/^d-out/.test(buffer)) {
console.log("end netproxy connection");
outConnection.end && outConnection.end();
return;
}
var t = parseInt(buffer.slice(0, i), 0);
buffer = "";
function wait() {
console.log("killed the process, waiting" + t + "ms before restart");
if (t > 1000) {
t -= 1000;
setTimeout(wait, 1000);
} else {
setTimeout(start, t);
}
}
wait();
stop();
});
start();
console.log(process.argv);

Wyświetl plik

@ -14,6 +14,16 @@ var Student = (function () {
return Student;
})();
var options = {x: 1}
function d(a) {
var options = {x: 2}
function e(a) {
var options = {x: 2}
console.log(1)
}
e()
}
d()
/**
* A greeter().
*/

Wyświetl plik

@ -184,6 +184,7 @@ define(function(require, exports, module) {
// Make sure home dir is marked correctly
path = path.replace(reHome, "~");
if (path[0] != "/") path = "/" + path;
fs.stat(path, function(err, stat) {
if (err) {