This commit is contained in:
Родитель
1ac133ea6f
Коммит
5a05992155
104
lib/_debugger.js
104
lib/_debugger.js
|
@ -5,7 +5,7 @@ var spawn = require('child_process').spawn;
|
|||
|
||||
exports.port = 5858;
|
||||
|
||||
exports.start = function () {
|
||||
exports.start = function() {
|
||||
var interface = new Interface();
|
||||
};
|
||||
|
||||
|
@ -22,12 +22,12 @@ args.unshift('--debug-brk');
|
|||
// Usage:
|
||||
// p = new Protocol();
|
||||
//
|
||||
// p.onResponse = function (res) {
|
||||
// p.onResponse = function(res) {
|
||||
// // do stuff with response from V8
|
||||
// };
|
||||
//
|
||||
// socket.setEncoding('utf8');
|
||||
// socket.on('data', function (s) {
|
||||
// socket.on('data', function(s) {
|
||||
// // Pass strings into the protocol
|
||||
// p.execute(s);
|
||||
// });
|
||||
|
@ -86,7 +86,7 @@ Protocol.prototype.execute = function(d) {
|
|||
break;
|
||||
|
||||
default:
|
||||
throw new Error("Unknown state");
|
||||
throw new Error('Unknown state');
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
@ -121,13 +121,13 @@ function Client() {
|
|||
});
|
||||
|
||||
protocol.onResponse = this._onResponse.bind(this);
|
||||
};
|
||||
}
|
||||
inherits(Client, net.Stream);
|
||||
exports.Client = Client;
|
||||
|
||||
|
||||
Client.prototype._addHandle = function(desc) {
|
||||
if (typeof desc != 'object' || !desc.handle) throw new Error("bad type");
|
||||
if (typeof desc != 'object' || !desc.handle) throw new Error('bad type');
|
||||
this.handles[desc.handle] = desc;
|
||||
|
||||
if (desc.type == 'script') {
|
||||
|
@ -201,7 +201,7 @@ Client.prototype.req = function(req, cb) {
|
|||
|
||||
|
||||
Client.prototype.reqVersion = function(cb) {
|
||||
this.req({ command: 'version' } , function (res) {
|
||||
this.req({ command: 'version' } , function(res) {
|
||||
if (cb) cb(res.body.V8Version, res.running);
|
||||
});
|
||||
};
|
||||
|
@ -221,7 +221,7 @@ Client.prototype.reqEval = function(expression, cb) {
|
|||
req.arguments.frame = this.currentFrame;
|
||||
}
|
||||
|
||||
this.req(req, function (res) {
|
||||
this.req(req, function(res) {
|
||||
console.error('reqEval res ', res.body);
|
||||
self._addHandle(res.body);
|
||||
if (cb) cb(res.body);
|
||||
|
@ -232,7 +232,7 @@ Client.prototype.reqEval = function(expression, cb) {
|
|||
// reqBacktrace(cb)
|
||||
// TODO: from, to, bottom
|
||||
Client.prototype.reqBacktrace = function(cb) {
|
||||
this.req({ command: 'backtrace' } , function (res) {
|
||||
this.req({ command: 'backtrace' } , function(res) {
|
||||
if (cb) cb(res.body);
|
||||
});
|
||||
};
|
||||
|
@ -256,7 +256,7 @@ Client.prototype.reqBacktrace = function(cb) {
|
|||
//
|
||||
Client.prototype.reqScripts = function(cb) {
|
||||
var self = this;
|
||||
this.req({ command: 'scripts' } , function (res) {
|
||||
this.req({ command: 'scripts' } , function(res) {
|
||||
for (var i = 0; i < res.body.length; i++) {
|
||||
self._addHandle(res.body[i]);
|
||||
}
|
||||
|
@ -266,13 +266,13 @@ Client.prototype.reqScripts = function(cb) {
|
|||
|
||||
|
||||
Client.prototype.reqContinue = function(cb) {
|
||||
this.req({ command: 'continue' }, function (res) {
|
||||
this.req({ command: 'continue' }, function(res) {
|
||||
if (cb) cb(res);
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.listbreakpoints = function(cb) {
|
||||
this.req({ command: 'listbreakpoints' }, function (res) {
|
||||
this.req({ command: 'listbreakpoints' }, function(res) {
|
||||
if (cb) cb(res);
|
||||
});
|
||||
};
|
||||
|
@ -284,7 +284,7 @@ Client.prototype.step = function(action, count, cb) {
|
|||
arguments: { stepaction: action, stepcount: count }
|
||||
};
|
||||
|
||||
this.req(req, function (res) {
|
||||
this.req(req, function(res) {
|
||||
if (cb) cb(res);
|
||||
});
|
||||
};
|
||||
|
@ -292,8 +292,8 @@ Client.prototype.step = function(action, count, cb) {
|
|||
|
||||
|
||||
|
||||
var helpMessage = "Commands: run, kill, print, step, next, " +
|
||||
"continue, scripts, backtrace, version, quit";
|
||||
var helpMessage = 'Commands: run, kill, print, step, next, ' +
|
||||
'continue, scripts, backtrace, version, quit';
|
||||
|
||||
function SourceUnderline(sourceText, position) {
|
||||
if (!sourceText) return;
|
||||
|
@ -342,7 +342,7 @@ function Interface() {
|
|||
var client;
|
||||
var term;
|
||||
|
||||
process.on('exit', function () {
|
||||
process.on('exit', function() {
|
||||
self.killChild();
|
||||
});
|
||||
|
||||
|
@ -356,15 +356,15 @@ function Interface() {
|
|||
|
||||
this.quitting = false;
|
||||
|
||||
process.on('SIGINT', function () {
|
||||
process.on('SIGINT', function() {
|
||||
self.handleSIGINT();
|
||||
});
|
||||
|
||||
term.on('SIGINT', function () {
|
||||
term.on('SIGINT', function() {
|
||||
self.handleSIGINT();
|
||||
});
|
||||
|
||||
term.on('close', function () {
|
||||
term.on('close', function() {
|
||||
self.tryQuit();
|
||||
});
|
||||
|
||||
|
@ -404,7 +404,7 @@ Interface.prototype.tryQuit = function() {
|
|||
var self = this;
|
||||
|
||||
if (self.child) {
|
||||
self.quitQuestion(function (yes) {
|
||||
self.quitQuestion(function(yes) {
|
||||
if (yes) {
|
||||
self.quit();
|
||||
} else {
|
||||
|
@ -425,7 +425,7 @@ Interface.prototype.pause = function() {
|
|||
|
||||
|
||||
Interface.prototype.resume = function() {
|
||||
if (!this.paused) return false
|
||||
if (!this.paused) return false;
|
||||
this.paused = false;
|
||||
this.stdin.resume();
|
||||
this.term.resume();
|
||||
|
@ -464,7 +464,7 @@ Interface.prototype.handleBreak = function(r) {
|
|||
|
||||
console.log(result);
|
||||
|
||||
if(!this.resume()) this.term.prompt();
|
||||
if (!this.resume()) this.term.prompt();
|
||||
};
|
||||
|
||||
|
||||
|
@ -481,15 +481,15 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
} else if (/^r(un)?/.test(cmd)) {
|
||||
self._lastCommand = null;
|
||||
if (self.child) {
|
||||
self.restartQuestion(function (yes) {
|
||||
self.restartQuestion(function(yes) {
|
||||
if (!yes) {
|
||||
self._lastCommand = null;
|
||||
term.prompt();
|
||||
} else {
|
||||
console.log("restarting...");
|
||||
console.log('restarting...');
|
||||
self.killChild();
|
||||
// XXX need to wait a little bit for the restart to work?
|
||||
setTimeout(function () {
|
||||
setTimeout(function() {
|
||||
self.trySpawn();
|
||||
}, 1000);
|
||||
}
|
||||
|
@ -507,7 +507,7 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
self.printNotConnected();
|
||||
return;
|
||||
}
|
||||
client.reqVersion(function (v) {
|
||||
client.reqVersion(function(v) {
|
||||
console.log(v);
|
||||
term.prompt();
|
||||
});
|
||||
|
@ -517,7 +517,7 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
self.printNotConnected();
|
||||
return;
|
||||
}
|
||||
client.listbreakpoints(function (res) {
|
||||
client.listbreakpoints(function(res) {
|
||||
console.log(res);
|
||||
term.prompt();
|
||||
});
|
||||
|
@ -527,7 +527,7 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
self.printNotConnected();
|
||||
return;
|
||||
}
|
||||
client.reqBacktrace(function (bt) {
|
||||
client.reqBacktrace(function(bt) {
|
||||
if (/full/.test(cmd)) {
|
||||
console.log(bt);
|
||||
} else if (bt.totalFrames == 0) {
|
||||
|
@ -558,7 +558,7 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
}
|
||||
|
||||
self.pause();
|
||||
client.reqContinue(function () {
|
||||
client.reqContinue(function() {
|
||||
self.resume();
|
||||
});
|
||||
|
||||
|
@ -569,7 +569,7 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
}
|
||||
// kill
|
||||
if (self.child) {
|
||||
self.killQuestion(function (yes) {
|
||||
self.killQuestion(function(yes) {
|
||||
if (yes) {
|
||||
self.killChild();
|
||||
} else {
|
||||
|
@ -585,7 +585,7 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
self.printNotConnected();
|
||||
return;
|
||||
}
|
||||
client.step('next', 1, function (res) {
|
||||
client.step('next', 1, function(res) {
|
||||
// Wait for break point. (disable raw mode?)
|
||||
});
|
||||
|
||||
|
@ -594,7 +594,7 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
self.printNotConnected();
|
||||
return;
|
||||
}
|
||||
client.step('in', 1, function (res) {
|
||||
client.step('in', 1, function(res) {
|
||||
// Wait for break point. (disable raw mode?)
|
||||
});
|
||||
|
||||
|
@ -605,11 +605,11 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
}
|
||||
var i = cmd.indexOf(' ');
|
||||
if (i < 0) {
|
||||
console.log("print [expression]");
|
||||
console.log('print [expression]');
|
||||
term.prompt();
|
||||
} else {
|
||||
cmd = cmd.slice(i);
|
||||
client.reqEval(cmd, function (res) {
|
||||
client.reqEval(cmd, function(res) {
|
||||
if (res) {
|
||||
console.log(res.text);
|
||||
} else {
|
||||
|
@ -633,13 +633,13 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||
Interface.prototype.yesNoQuestion = function(prompt, cb) {
|
||||
var self = this;
|
||||
self.resume();
|
||||
this.term.question(prompt, function (answer) {
|
||||
this.term.question(prompt, function(answer) {
|
||||
if (/^y(es)?$/i.test(answer)) {
|
||||
cb(true);
|
||||
} else if (/^n(o)?$/i.test(answer)) {
|
||||
cb(false);
|
||||
} else {
|
||||
console.log("Please answer y or n.");
|
||||
console.log('Please answer y or n.');
|
||||
self.restartQuestion(cb);
|
||||
}
|
||||
});
|
||||
|
@ -647,18 +647,18 @@ Interface.prototype.yesNoQuestion = function(prompt, cb) {
|
|||
|
||||
|
||||
Interface.prototype.restartQuestion = function(cb) {
|
||||
this.yesNoQuestion("The program being debugged has been started already.\n" +
|
||||
"Start it from the beginning? (y or n) ", cb);
|
||||
this.yesNoQuestion('The program being debugged has been started already.\n' +
|
||||
'Start it from the beginning? (y or n) ', cb);
|
||||
};
|
||||
|
||||
|
||||
Interface.prototype.killQuestion = function(cb) {
|
||||
this.yesNoQuestion("Kill the program being debugged? (y or n) ", cb);
|
||||
this.yesNoQuestion('Kill the program being debugged? (y or n) ', cb);
|
||||
};
|
||||
|
||||
|
||||
Interface.prototype.quitQuestion = function(cb) {
|
||||
this.yesNoQuestion("A debugging session is active. Quit anyway? (y or n) ",
|
||||
this.yesNoQuestion('A debugging session is active. Quit anyway? (y or n) ',
|
||||
cb);
|
||||
};
|
||||
|
||||
|
@ -688,35 +688,35 @@ Interface.prototype.trySpawn = function(cb) {
|
|||
|
||||
this.pause();
|
||||
|
||||
setTimeout(function () {
|
||||
process.stdout.write("connecting...");
|
||||
setTimeout(function() {
|
||||
process.stdout.write('connecting...');
|
||||
var client = self.client = new Client();
|
||||
client.connect(exports.port);
|
||||
|
||||
client.once('ready', function () {
|
||||
process.stdout.write("ok\r\n");
|
||||
client.once('ready', function() {
|
||||
process.stdout.write('ok\r\n');
|
||||
|
||||
// since we did debug-brk, we're hitting a break point immediately
|
||||
// continue before anything else.
|
||||
client.reqContinue(function () {
|
||||
client.reqContinue(function() {
|
||||
if (cb) cb();
|
||||
});
|
||||
});
|
||||
|
||||
client.on('close', function () {
|
||||
console.log("\nprogram terminated");
|
||||
client.on('close', function() {
|
||||
console.log('\nprogram terminated');
|
||||
self.client = null;
|
||||
self.killChild();
|
||||
if (!self.quitting) self.term.prompt();
|
||||
});
|
||||
|
||||
client.on('unhandledResponse', function (res) {
|
||||
console.log("\r\nunhandled res:");
|
||||
client.on('unhandledResponse', function(res) {
|
||||
console.log('\r\nunhandled res:');
|
||||
console.log(res);
|
||||
self.term.prompt();
|
||||
});
|
||||
|
||||
client.on('break', function (res) {
|
||||
client.on('break', function(res) {
|
||||
self.handleBreak(res.body);
|
||||
});
|
||||
}, 100);
|
||||
|
@ -736,7 +736,9 @@ Interface.prototype.printScripts = function(displayNatives) {
|
|||
for (var id in client.scripts) {
|
||||
var script = client.scripts[id];
|
||||
if (typeof script == 'object' && script.name) {
|
||||
if (displayNatives || script.name == client.currentScript || !script.isNative) {
|
||||
if (displayNatives ||
|
||||
script.name == client.currentScript ||
|
||||
!script.isNative) {
|
||||
text += script.name == client.currentScript ? '* ' : ' ';
|
||||
var n = require('path').split(script.name);
|
||||
text += n[n.length - 1] + '\n';
|
||||
|
|
|
@ -249,7 +249,7 @@ function expectedException(actual, expected) {
|
|||
return expected.test(actual);
|
||||
} else if (actual instanceof expected) {
|
||||
return true;
|
||||
} else if ( expected.call({}, actual) === true ) {
|
||||
} else if (expected.call({}, actual) === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
30
lib/fs.js
30
lib/fs.js
|
@ -529,10 +529,14 @@ if (isWindows) {
|
|||
var seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
var pos = 0, // current character position in p
|
||||
current = "", // the partial path so far, including a trailing slash if any
|
||||
base = "", // the partial path without a trailing slash
|
||||
previous = ""; // the partial path scanned in the previous round, with slash
|
||||
// current character position in p
|
||||
var pos = 0;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current = '';
|
||||
// the partial path without a trailing slash
|
||||
var base = '';
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous = '';
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
|
@ -566,10 +570,10 @@ if (isWindows) {
|
|||
// resolve the link, then start over
|
||||
p = path.resolve(previous, seenLinks[id], p.slice(pos));
|
||||
pos = 0;
|
||||
previous = base = current = "";
|
||||
previous = base = current = '';
|
||||
}
|
||||
|
||||
return p;
|
||||
return p;
|
||||
};
|
||||
|
||||
|
||||
|
@ -581,10 +585,14 @@ if (isWindows) {
|
|||
var seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
var pos = 0, // current character position in p
|
||||
current = "", // the partial path so far, including a trailing slash if any
|
||||
base = "", // the partial path without a trailing slash
|
||||
previous = ""; // the partial path scanned in the previous round, with slash
|
||||
// current character position in p
|
||||
var pos = 0;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current = '';
|
||||
// the partial path without a trailing slash
|
||||
var base = '';
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous = '';
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
|
@ -641,7 +649,7 @@ if (isWindows) {
|
|||
// resolve the link, then start over
|
||||
p = path.resolve(previous, target, p.slice(pos));
|
||||
pos = 0;
|
||||
previous = base = current = "";
|
||||
previous = base = current = '';
|
||||
|
||||
return process.nextTick(LOOP);
|
||||
}
|
||||
|
|
|
@ -320,7 +320,7 @@ Socket.prototype.write = function(data /* [encoding], [fd], [cb] */) {
|
|||
this._writeQueueCallbacks[last] = cb;
|
||||
} else {
|
||||
// awful
|
||||
this._writeQueueCallbacks[last] = function () {
|
||||
this._writeQueueCallbacks[last] = function() {
|
||||
this._writeQueueCallbacks[last]();
|
||||
cb();
|
||||
};
|
||||
|
|
|
@ -8,4 +8,5 @@ exports.totalmem = binding.getTotalMem;
|
|||
exports.cpus = binding.getCPUs;
|
||||
exports.type = binding.getOSType;
|
||||
exports.release = binding.getOSRelease;
|
||||
exports.isWindows = binding.isWindows;
|
||||
exports.isWindows = binding.isWindows;
|
||||
|
||||
|
|
84
lib/path.js
84
lib/path.js
|
@ -2,9 +2,10 @@
|
|||
var isWindows = process.platform === 'win32';
|
||||
|
||||
|
||||
// resolves . and .. elements in a path array with directory names
|
||||
// there must be no slashes, empty elements, or device names (c:\) in the array
|
||||
// (so also no leading and trailing slashes - it does not distinguish relative and absolute paths)
|
||||
// resolves . and .. elements in a path array with directory names there
|
||||
// must be no slashes, empty elements, or device names (c:\) in the array
|
||||
// (so also no leading and trailing slashes - it does not distinguish
|
||||
// relative and absolute paths)
|
||||
function normalizeArray(parts, allowAboveRoot) {
|
||||
// if the path tries to go above the root, `up` ends up > 0
|
||||
var up = 0;
|
||||
|
@ -23,7 +24,7 @@ function normalizeArray(parts, allowAboveRoot) {
|
|||
|
||||
// if the path is allowed to go above the root, restore leading ..s
|
||||
if (allowAboveRoot) {
|
||||
for ( ; up--; up) {
|
||||
for (; up--; up) {
|
||||
parts.unshift('..');
|
||||
}
|
||||
}
|
||||
|
@ -38,18 +39,20 @@ if (isWindows) {
|
|||
// windows version
|
||||
var splitPathRe = /^(.+(?:[\\\/](?!$)|:)|[\\\/])?((?:.+?)?(\.[^.]*)?)$/;
|
||||
|
||||
// Regex to split a windows path into three parts: [*, device, slash, tail]
|
||||
// windows-only
|
||||
var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?(.*?)$/;
|
||||
// Regex to split a windows path into three parts: [*, device, slash,
|
||||
// tail] windows-only
|
||||
var splitDeviceRe =
|
||||
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?(.*?)$/;
|
||||
|
||||
// path.resolve([from ...], to)
|
||||
// windows version
|
||||
exports.resolve = function() {
|
||||
// Prepend cwd to provided paths
|
||||
var paths = [process.cwd()].concat(Array.prototype.slice.call(arguments, 0));
|
||||
var paths = [process.cwd()].concat(
|
||||
Array.prototype.slice.call(arguments, 0));
|
||||
|
||||
var resolvedDevice = "",
|
||||
resolvedTail = "",
|
||||
var resolvedDevice = '',
|
||||
resolvedTail = '',
|
||||
resolvedAbsolute = false;
|
||||
|
||||
for (var i = paths.length; i >= 0; i--) {
|
||||
|
@ -66,7 +69,9 @@ if (isWindows) {
|
|||
isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute
|
||||
tail = result[3];
|
||||
|
||||
if (device && resolvedDevice && device.toLowerCase() !== resolvedDevice.toLowerCase()) {
|
||||
if (device &&
|
||||
resolvedDevice &&
|
||||
device.toLowerCase() !== resolvedDevice.toLowerCase()) {
|
||||
// This path points to another device so it is not applicable
|
||||
continue;
|
||||
}
|
||||
|
@ -92,7 +97,7 @@ if (isWindows) {
|
|||
// Windows stores the current directories for 'other' drives
|
||||
// as hidden environment variables like =C:=c:\windows (literally)
|
||||
// var deviceCwd = os.getCwdForDrive(resolvedDevice);
|
||||
var deviceCwd = "";
|
||||
var deviceCwd = '';
|
||||
|
||||
// If there is no cwd set for the drive, it is at root
|
||||
resolvedTail = deviceCwd + '\\' + resolvedTail;
|
||||
|
@ -102,16 +107,22 @@ if (isWindows) {
|
|||
// Replace slashes (in UNC share name) by backslashes
|
||||
resolvedDevice = resolvedDevice.replace(/\//g, '\\');
|
||||
|
||||
// At this point the path should be resolved to a full absolute path, but
|
||||
// handle relative paths to be safe (might happen when process.cwd() fails)
|
||||
// At this point the path should be resolved to a full absolute path,
|
||||
// but handle relative paths to be safe (might happen when process.cwd()
|
||||
// fails)
|
||||
|
||||
// Normalize the tail path
|
||||
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(function(p) {
|
||||
return !!p;
|
||||
}), !resolvedAbsolute).join('\\');
|
||||
|
||||
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) || '.';
|
||||
}
|
||||
function f(p) {
|
||||
return !!p;
|
||||
}
|
||||
|
||||
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(f),
|
||||
!resolvedAbsolute).join('\\');
|
||||
|
||||
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
|
||||
'.';
|
||||
};
|
||||
|
||||
// windows version
|
||||
exports.normalize = function(path) {
|
||||
|
@ -128,21 +139,23 @@ if (isWindows) {
|
|||
}), !isAbsolute).join('\\');
|
||||
|
||||
if (!tail && !isAbsolute) {
|
||||
tail = '.'
|
||||
tail = '.';
|
||||
}
|
||||
if (tail && trailingSlash) {
|
||||
tail += '\\'
|
||||
tail += '\\';
|
||||
}
|
||||
|
||||
return device + (isAbsolute ? '\\' : '') + tail;
|
||||
}
|
||||
};
|
||||
|
||||
// windows version
|
||||
exports.join = function() {
|
||||
var paths = Array.prototype.slice.call(arguments, 0).filter(function(p) {
|
||||
return p && typeof p === 'string';
|
||||
}),
|
||||
joined = paths.join('\\');
|
||||
function f(p) {
|
||||
return p && typeof p === 'string';
|
||||
}
|
||||
|
||||
var paths = Array.prototype.slice.call(arguments, 0).filter(f);
|
||||
var joined = paths.join('\\');
|
||||
|
||||
// Make sure that the joined path doesn't start with two slashes
|
||||
// - it will be mistaken for an unc path by normalize() -
|
||||
|
@ -152,7 +165,7 @@ if (isWindows) {
|
|||
}
|
||||
|
||||
return exports.normalize(joined);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} else /* posix */ {
|
||||
|
@ -165,9 +178,10 @@ if (isWindows) {
|
|||
// posix version
|
||||
exports.resolve = function() {
|
||||
// Prepend cwd to provided paths
|
||||
var paths = [process.cwd()].concat(Array.prototype.slice.call(arguments, 0));
|
||||
var paths = [process.cwd()].concat(
|
||||
Array.prototype.slice.call(arguments, 0));
|
||||
|
||||
var resolvedPath = "",
|
||||
var resolvedPath = '',
|
||||
resolvedAbsolute = false;
|
||||
|
||||
for (var i = paths.length; i >= 0 && !resolvedAbsolute; i--) {
|
||||
|
@ -189,7 +203,7 @@ if (isWindows) {
|
|||
}), !resolvedAbsolute).join('/');
|
||||
|
||||
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
||||
}
|
||||
};
|
||||
|
||||
// path.normalize(path)
|
||||
// posix version
|
||||
|
@ -203,23 +217,23 @@ if (isWindows) {
|
|||
}), !isAbsolute).join('/');
|
||||
|
||||
if (!path && !isAbsolute) {
|
||||
path = '.'
|
||||
path = '.';
|
||||
}
|
||||
if (path && trailingSlash) {
|
||||
path += '/';
|
||||
}
|
||||
|
||||
return (isAbsolute ? '/' : '') + path;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// posix version
|
||||
exports.join = function() {
|
||||
var paths = Array.prototype.slice.call(arguments, 0);
|
||||
return exports.normalize(paths.filter(function(p, index) {
|
||||
return p && typeof p === 'string'
|
||||
return p && typeof p === 'string';
|
||||
}).join('/'));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
@ -227,7 +241,7 @@ exports.dirname = function(path) {
|
|||
var dir = splitPathRe.exec(path)[1] || '';
|
||||
if (!dir) {
|
||||
// No dirname
|
||||
return '.'
|
||||
return '.';
|
||||
} else if (dir.length === 1 ||
|
||||
(isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
|
||||
// It is just a slash or a drive letter with a slash
|
||||
|
|
|
@ -109,7 +109,7 @@ Interface.prototype._onLine = function(line) {
|
|||
var cb = this._questionCallback;
|
||||
this._questionCallback = null;
|
||||
this.setPrompt(this._oldPrompt);
|
||||
cb(line)
|
||||
cb(line);
|
||||
} else {
|
||||
this.emit('line', line);
|
||||
}
|
||||
|
|
|
@ -128,9 +128,11 @@ function REPLServer(prompt, stream) {
|
|||
try {
|
||||
// First we attempt to eval as expression with parens.
|
||||
// This catches '{a : 1}' properly.
|
||||
ret = vm.runInContext('(' + self.bufferedCommand + ')', context, 'repl');
|
||||
ret = vm.runInContext('(' + self.bufferedCommand + ')',
|
||||
context,
|
||||
'repl');
|
||||
if (typeof ret !== 'function') success = true;
|
||||
} catch (e) {
|
||||
} catch (e) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
|
18
lib/tls.js
18
lib/tls.js
|
@ -16,15 +16,14 @@ if (process.env.NODE_DEBUG && /tls/.test(process.env.NODE_DEBUG)) {
|
|||
|
||||
var Connection = null;
|
||||
try {
|
||||
Connection = process.binding('crypto').Connection;
|
||||
}
|
||||
catch (e) {
|
||||
Connection = process.binding('crypto').Connection;
|
||||
} catch (e) {
|
||||
throw new Error('node.js not compiled with openssl crypto support.');
|
||||
}
|
||||
|
||||
|
||||
// Base class of both CleartextStream and EncryptedStream
|
||||
function CryptoStream (pair) {
|
||||
function CryptoStream(pair) {
|
||||
stream.Stream.call(this);
|
||||
|
||||
this.pair = pair;
|
||||
|
@ -82,8 +81,8 @@ CryptoStream.prototype.setTimeout = function(n) {
|
|||
};
|
||||
|
||||
|
||||
function parseCertString (s) {
|
||||
// EG '/C=US/ST=CA/L=SF/O=Joyent/OU=Node.js/CN=ca1/emailAddress=ry@tinyclouds.org'
|
||||
// EG '/C=US/ST=CA/L=SF/O=Joyent/OU=Node.js/CN=ca1/emailAddress=ry@clouds.org'
|
||||
function parseCertString(s) {
|
||||
var out = {};
|
||||
var parts = s.split('/');
|
||||
// Note: can always skip the first one.
|
||||
|
@ -267,7 +266,7 @@ CryptoStream.prototype._suck = function() {
|
|||
};
|
||||
|
||||
|
||||
function CleartextStream (pair) {
|
||||
function CleartextStream(pair) {
|
||||
CryptoStream.call(this, pair);
|
||||
}
|
||||
util.inherits(CleartextStream, CryptoStream);
|
||||
|
@ -286,7 +285,7 @@ CleartextStream.prototype._blower = function(pool, offset, length) {
|
|||
};
|
||||
|
||||
|
||||
function EncryptedStream (pair) {
|
||||
function EncryptedStream(pair) {
|
||||
CryptoStream.call(this, pair);
|
||||
}
|
||||
util.inherits(EncryptedStream, CryptoStream);
|
||||
|
@ -380,8 +379,7 @@ exports.createSecurePair = function(credentials,
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to cycle OpenSSLs buffers in various directions.
|
||||
/* Attempt to cycle OpenSSLs buffers in various directions.
|
||||
*
|
||||
* An SSL Connection can be viewed as four separate piplines,
|
||||
* interacting with one has no connection to the behavoir of
|
||||
|
|
|
@ -305,7 +305,7 @@ function urlResolveObject(source, relative) {
|
|||
|
||||
// if the path is allowed to go above the root, restore leading ..s
|
||||
if (!mustEndAbs && !removeAllDots) {
|
||||
for ( ; up--; up) {
|
||||
for (; up--; up) {
|
||||
srcPath.unshift('..');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,11 @@
|
|||
|
||||
var path = requireNative('path');
|
||||
|
||||
var modulePaths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];
|
||||
var modulePaths = [path.resolve(process.execPath,
|
||||
'..',
|
||||
'..',
|
||||
'lib',
|
||||
'node')];
|
||||
|
||||
if (process.env['HOME']) {
|
||||
modulePaths.unshift(path.resolve(process.env['HOME'], '.node_libraries'));
|
||||
|
|
Загрузка…
Ссылка в новой задаче