node without arguments starts the REPL

This commit is contained in:
Ryan Dahl 2010-06-07 16:15:41 -07:00
Родитель e43d6fc879
Коммит 6056d2ea2c
4 изменённых файлов: 20 добавлений и 20 удалений

Просмотреть файл

@ -1,8 +1,9 @@
#!/usr/bin/env node
puts = require("sys").puts;
var puts = require("sys").puts;
puts("Type '.help' for options.");
puts("(The REPL can also be started by typing 'node' without arguments)");
require('repl').start();

Просмотреть файл

@ -441,16 +441,6 @@ Module.prototype._waitChildrenLoad = function (callback) {
// bootstrap main module.
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.
process.mainModule = new Module(".");

Просмотреть файл

@ -2098,14 +2098,6 @@ int main(int argc, char *argv[]) {
// in the command line))
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
struct sigaction sa;
bzero(&sa, sizeof(sa));

Просмотреть файл

@ -192,9 +192,26 @@ process.exit = function (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
// might even have created TCP servers. Now we enter the main eventloop. If