node without arguments starts the REPL
This commit is contained in:
parent
e43d6fc879
commit
6056d2ea2c
@ -1,8 +1,9 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
puts = require("sys").puts;
|
var puts = require("sys").puts;
|
||||||
|
|
||||||
puts("Type '.help' for options.");
|
puts("Type '.help' for options.");
|
||||||
|
puts("(The REPL can also be started by typing 'node' without arguments)");
|
||||||
|
|
||||||
require('repl').start();
|
require('repl').start();
|
||||||
|
|
||||||
|
@ -441,16 +441,6 @@ Module.prototype._waitChildrenLoad = function (callback) {
|
|||||||
|
|
||||||
// bootstrap main module.
|
// bootstrap main module.
|
||||||
exports.runMain = function () {
|
exports.runMain = function () {
|
||||||
var cwd = process.cwd();
|
|
||||||
|
|
||||||
// Make process.argv[0] and process.argv[1] into full paths.
|
|
||||||
if (process.argv[0].indexOf('/') > 0) {
|
|
||||||
process.argv[0] = path.join(cwd, process.argv[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv[1].charAt(0) != "/" && !(/^http:\/\//).exec(process.argv[1])) {
|
|
||||||
process.argv[1] = path.join(cwd, process.argv[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the main module--the command line argument.
|
// Load the main module--the command line argument.
|
||||||
process.mainModule = new Module(".");
|
process.mainModule = new Module(".");
|
||||||
|
@ -2098,14 +2098,6 @@ int main(int argc, char *argv[]) {
|
|||||||
// in the command line))
|
// in the command line))
|
||||||
V8::SetFlagsFromCommandLine(&node::option_end_index, argv, false);
|
V8::SetFlagsFromCommandLine(&node::option_end_index, argv, false);
|
||||||
|
|
||||||
// Error out if we don't have a script argument.
|
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "No script was specified.\n");
|
|
||||||
node::PrintHelp();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Ignore SIGPIPE
|
// Ignore SIGPIPE
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
bzero(&sa, sizeof(sa));
|
bzero(&sa, sizeof(sa));
|
||||||
|
19
src/node.js
19
src/node.js
@ -192,9 +192,26 @@ process.exit = function (code) {
|
|||||||
process.reallyExit(code);
|
process.reallyExit(code);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var cwd = process.cwd();
|
||||||
|
var path = module.requireNative('path');
|
||||||
|
|
||||||
module.runMain();
|
// Make process.argv[0] and process.argv[1] into full paths.
|
||||||
|
if (process.argv[0].indexOf('/') > 0) {
|
||||||
|
process.argv[0] = path.join(cwd, process.argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1]) {
|
||||||
|
if (process.argv[1].charAt(0) != "/" && !(/^http:\/\//).exec(process.argv[1])) {
|
||||||
|
process.argv[1] = path.join(cwd, process.argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.runMain();
|
||||||
|
} else {
|
||||||
|
// No arguments, run the repl
|
||||||
|
var repl = module.requireNative('repl');
|
||||||
|
process.stdout.write("Type '.help' for options.\n");
|
||||||
|
repl.start();
|
||||||
|
}
|
||||||
|
|
||||||
// All our arguments are loaded. We've evaluated all of the scripts. We
|
// All our arguments are loaded. We've evaluated all of the scripts. We
|
||||||
// might even have created TCP servers. Now we enter the main eventloop. If
|
// might even have created TCP servers. Now we enter the main eventloop. If
|
||||||
|
Loading…
x
Reference in New Issue
Block a user