Browse Source

node without arguments starts the REPL

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
6056d2ea2c
  1. 3
      bin/node-repl
  2. 10
      lib/module.js
  3. 8
      src/node.cc
  4. 19
      src/node.js

3
bin/node-repl

@ -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();

10
lib/module.js

@ -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(".");

8
src/node.cc

@ -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));

19
src/node.js

@ -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

Loading…
Cancel
Save