Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: revert -r/--require flags #1150

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions doc/iojs.1
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ and servers.
-i, --interactive always enter the REPL even if stdin
does not appear to be a terminal

-r, --require module to preload at startup

--no-deprecation silence deprecation warnings

--trace-deprecation show stack traces on deprecations
Expand Down
37 changes: 0 additions & 37 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ static bool trace_deprecation = false;
static bool throw_deprecation = false;
static bool abort_on_uncaught_exception = false;
static const char* eval_string = nullptr;
static unsigned int preload_module_count = 0;
static const char** preload_modules = nullptr;
static bool use_debug_agent = false;
static bool debug_wait_connect = false;
static int debug_port = 5858;
Expand Down Expand Up @@ -2767,19 +2765,6 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(process, "_forceRepl", True(env->isolate()));
}

if (preload_module_count) {
CHECK(preload_modules);
Local<Array> array = Array::New(env->isolate());
for (unsigned int i = 0; i < preload_module_count; ++i) {
Local<String> module = String::NewFromUtf8(env->isolate(),
preload_modules[i]);
array->Set(i, module);
}
READONLY_PROPERTY(process,
"_preload_modules",
array);
}

// --no-deprecation
if (no_deprecation) {
READONLY_PROPERTY(process, "noDeprecation", True(env->isolate()));
Expand Down Expand Up @@ -3004,7 +2989,6 @@ static void PrintHelp() {
" -p, --print evaluate script and print result\n"
" -i, --interactive always enter the REPL even if stdin\n"
" does not appear to be a terminal\n"
" -r, --require module to preload (option can be repeated)\n"
" --no-deprecation silence deprecation warnings\n"
" --throw-deprecation throw an exception anytime a deprecated "
"function is used\n"
Expand Down Expand Up @@ -3062,13 +3046,11 @@ static void ParseArgs(int* argc,
const char** new_exec_argv = new const char*[nargs];
const char** new_v8_argv = new const char*[nargs];
const char** new_argv = new const char*[nargs];
const char** local_preload_modules = new const char*[nargs];

for (unsigned int i = 0; i < nargs; ++i) {
new_exec_argv[i] = nullptr;
new_v8_argv[i] = nullptr;
new_argv[i] = nullptr;
local_preload_modules[i] = nullptr;
}

// exec_argv starts with the first option, the other two start with argv[0].
Expand Down Expand Up @@ -3117,15 +3099,6 @@ static void ParseArgs(int* argc,
eval_string += 1;
}
}
} else if (strcmp(arg, "--require") == 0 ||
strcmp(arg, "-r") == 0) {
const char* module = argv[index + 1];
if (module == nullptr) {
fprintf(stderr, "%s: %s requires an argument\n", argv[0], arg);
exit(9);
}
args_consumed += 1;
local_preload_modules[preload_module_count++] = module;
} else if (strcmp(arg, "--interactive") == 0 || strcmp(arg, "-i") == 0) {
force_repl = true;
} else if (strcmp(arg, "--no-deprecation") == 0) {
Expand Down Expand Up @@ -3172,16 +3145,6 @@ static void ParseArgs(int* argc,
memcpy(argv, new_argv, new_argc * sizeof(*argv));
delete[] new_argv;
*argc = static_cast<int>(new_argc);

// Copy the preload_modules from the local array to an appropriately sized
// global array.
if (preload_module_count > 0) {
CHECK(!preload_modules);
preload_modules = new const char*[preload_module_count];
memcpy(preload_modules, local_preload_modules,
preload_module_count * sizeof(*preload_modules));
}
delete[] local_preload_modules;
}


Expand Down
142 changes: 65 additions & 77 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,96 +68,84 @@
var d = NativeModule.require('_debug_agent');
d.start();

} else {
// There is user code to be run
} else if (process._eval != null) {
// User passed '-e' or '--eval' arguments to Node.
evalScript('[eval]');
} else if (process.argv[1]) {
// make process.argv[1] into a full path
var path = NativeModule.require('path');
process.argv[1] = path.resolve(process.argv[1]);

// Load any preload modules
if (process._preload_modules) {
var Module = NativeModule.require('module');
process._preload_modules.forEach(function(module) {
Module._load(module);
});
// If this is a worker in cluster mode, start up the communication
// channel.
if (process.env.NODE_UNIQUE_ID) {
var cluster = NativeModule.require('cluster');
cluster._setupWorker();

// Make sure it's not accidentally inherited by child processes.
delete process.env.NODE_UNIQUE_ID;
}

if (process._eval != null) {
// User passed '-e' or '--eval' arguments to Node.
evalScript('[eval]');
} else if (process.argv[1]) {
// make process.argv[1] into a full path
var path = NativeModule.require('path');
process.argv[1] = path.resolve(process.argv[1]);

// If this is a worker in cluster mode, start up the communication
// channel.
if (process.env.NODE_UNIQUE_ID) {
var cluster = NativeModule.require('cluster');
cluster._setupWorker();

// Make sure it's not accidentally inherited by child processes.
delete process.env.NODE_UNIQUE_ID;
}
var Module = NativeModule.require('module');

var Module = NativeModule.require('module');
if (global.v8debug &&
process.execArgv.some(function(arg) {
return arg.match(/^--debug-brk(=[0-9]*)?$/);
})) {

if (global.v8debug &&
process.execArgv.some(function(arg) {
return arg.match(/^--debug-brk(=[0-9]*)?$/);
})) {
// XXX Fix this terrible hack!
//
// Give the client program a few ticks to connect.
// Otherwise, there's a race condition where `node debug foo.js`
// will not be able to connect in time to catch the first
// breakpoint message on line 1.
//
// A better fix would be to somehow get a message from the
// global.v8debug object about a connection, and runMain when
// that occurs. --isaacs

// XXX Fix this terrible hack!
//
// Give the client program a few ticks to connect.
// Otherwise, there's a race condition where `node debug foo.js`
// will not be able to connect in time to catch the first
// breakpoint message on line 1.
//
// A better fix would be to somehow get a message from the
// global.v8debug object about a connection, and runMain when
// that occurs. --isaacs
var debugTimeout = +process.env.NODE_DEBUG_TIMEOUT || 50;
setTimeout(Module.runMain, debugTimeout);

var debugTimeout = +process.env.NODE_DEBUG_TIMEOUT || 50;
setTimeout(Module.runMain, debugTimeout);
} else {
// Main entry point into most programs:
Module.runMain();
}

} else {
// Main entry point into most programs:
Module.runMain();
} else {
var Module = NativeModule.require('module');

// If -i or --interactive were passed, or stdin is a TTY.
if (process._forceRepl || NativeModule.require('tty').isatty(0)) {
// REPL
var opts = {
useGlobal: true,
ignoreUndefined: false
};
if (parseInt(process.env['NODE_NO_READLINE'], 10)) {
opts.terminal = false;
}
if (parseInt(process.env['NODE_DISABLE_COLORS'], 10)) {
opts.useColors = false;
}
var repl = Module.requireRepl().start(opts);
repl.on('exit', function() {
process.exit();
});

} else {
var Module = NativeModule.require('module');

// If -i or --interactive were passed, or stdin is a TTY.
if (process._forceRepl || NativeModule.require('tty').isatty(0)) {
// REPL
var opts = {
useGlobal: true,
ignoreUndefined: false
};
if (parseInt(process.env['NODE_NO_READLINE'], 10)) {
opts.terminal = false;
}
if (parseInt(process.env['NODE_DISABLE_COLORS'], 10)) {
opts.useColors = false;
}
var repl = Module.requireRepl().start(opts);
repl.on('exit', function() {
process.exit();
});

} else {
// Read all of stdin - execute it.
process.stdin.setEncoding('utf8');
// Read all of stdin - execute it.
process.stdin.setEncoding('utf8');

var code = '';
process.stdin.on('data', function(d) {
code += d;
});
var code = '';
process.stdin.on('data', function(d) {
code += d;
});

process.stdin.on('end', function() {
process._eval = code;
evalScript('[stdin]');
});
}
process.stdin.on('end', function() {
process._eval = code;
evalScript('[stdin]');
});
}
}
}
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/printA.js

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/printB.js

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/printC.js

This file was deleted.

75 changes: 0 additions & 75 deletions test/parallel/test-preload.js

This file was deleted.