Skip to content

Commit 056ed4b

Browse files
src: revert -r/--require flags
This reverts commit 7bde3f1. The added test (test/parallel/test-preload.js) fails on Windows. PR-URL: #1150 Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 7a5b023 commit 056ed4b

File tree

7 files changed

+65
-194
lines changed

7 files changed

+65
-194
lines changed

doc/iojs.1

-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ and servers.
5252
-i, --interactive always enter the REPL even if stdin
5353
does not appear to be a terminal
5454

55-
-r, --require module to preload at startup
56-
5755
--no-deprecation silence deprecation warnings
5856

5957
--trace-deprecation show stack traces on deprecations

src/node.cc

-37
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ static bool trace_deprecation = false;
114114
static bool throw_deprecation = false;
115115
static bool abort_on_uncaught_exception = false;
116116
static const char* eval_string = nullptr;
117-
static unsigned int preload_module_count = 0;
118-
static const char** preload_modules = nullptr;
119117
static bool use_debug_agent = false;
120118
static bool debug_wait_connect = false;
121119
static int debug_port = 5858;
@@ -2767,19 +2765,6 @@ void SetupProcessObject(Environment* env,
27672765
READONLY_PROPERTY(process, "_forceRepl", True(env->isolate()));
27682766
}
27692767

2770-
if (preload_module_count) {
2771-
CHECK(preload_modules);
2772-
Local<Array> array = Array::New(env->isolate());
2773-
for (unsigned int i = 0; i < preload_module_count; ++i) {
2774-
Local<String> module = String::NewFromUtf8(env->isolate(),
2775-
preload_modules[i]);
2776-
array->Set(i, module);
2777-
}
2778-
READONLY_PROPERTY(process,
2779-
"_preload_modules",
2780-
array);
2781-
}
2782-
27832768
// --no-deprecation
27842769
if (no_deprecation) {
27852770
READONLY_PROPERTY(process, "noDeprecation", True(env->isolate()));
@@ -3004,7 +2989,6 @@ static void PrintHelp() {
30042989
" -p, --print evaluate script and print result\n"
30052990
" -i, --interactive always enter the REPL even if stdin\n"
30062991
" does not appear to be a terminal\n"
3007-
" -r, --require module to preload (option can be repeated)\n"
30082992
" --no-deprecation silence deprecation warnings\n"
30092993
" --throw-deprecation throw an exception anytime a deprecated "
30102994
"function is used\n"
@@ -3062,13 +3046,11 @@ static void ParseArgs(int* argc,
30623046
const char** new_exec_argv = new const char*[nargs];
30633047
const char** new_v8_argv = new const char*[nargs];
30643048
const char** new_argv = new const char*[nargs];
3065-
const char** local_preload_modules = new const char*[nargs];
30663049

30673050
for (unsigned int i = 0; i < nargs; ++i) {
30683051
new_exec_argv[i] = nullptr;
30693052
new_v8_argv[i] = nullptr;
30703053
new_argv[i] = nullptr;
3071-
local_preload_modules[i] = nullptr;
30723054
}
30733055

30743056
// exec_argv starts with the first option, the other two start with argv[0].
@@ -3117,15 +3099,6 @@ static void ParseArgs(int* argc,
31173099
eval_string += 1;
31183100
}
31193101
}
3120-
} else if (strcmp(arg, "--require") == 0 ||
3121-
strcmp(arg, "-r") == 0) {
3122-
const char* module = argv[index + 1];
3123-
if (module == nullptr) {
3124-
fprintf(stderr, "%s: %s requires an argument\n", argv[0], arg);
3125-
exit(9);
3126-
}
3127-
args_consumed += 1;
3128-
local_preload_modules[preload_module_count++] = module;
31293102
} else if (strcmp(arg, "--interactive") == 0 || strcmp(arg, "-i") == 0) {
31303103
force_repl = true;
31313104
} else if (strcmp(arg, "--no-deprecation") == 0) {
@@ -3172,16 +3145,6 @@ static void ParseArgs(int* argc,
31723145
memcpy(argv, new_argv, new_argc * sizeof(*argv));
31733146
delete[] new_argv;
31743147
*argc = static_cast<int>(new_argc);
3175-
3176-
// Copy the preload_modules from the local array to an appropriately sized
3177-
// global array.
3178-
if (preload_module_count > 0) {
3179-
CHECK(!preload_modules);
3180-
preload_modules = new const char*[preload_module_count];
3181-
memcpy(preload_modules, local_preload_modules,
3182-
preload_module_count * sizeof(*preload_modules));
3183-
}
3184-
delete[] local_preload_modules;
31853148
}
31863149

31873150

src/node.js

+65-77
Original file line numberDiff line numberDiff line change
@@ -68,96 +68,84 @@
6868
var d = NativeModule.require('_debug_agent');
6969
d.start();
7070

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

74-
// Load any preload modules
75-
if (process._preload_modules) {
76-
var Module = NativeModule.require('module');
77-
process._preload_modules.forEach(function(module) {
78-
Module._load(module);
79-
});
79+
// If this is a worker in cluster mode, start up the communication
80+
// channel.
81+
if (process.env.NODE_UNIQUE_ID) {
82+
var cluster = NativeModule.require('cluster');
83+
cluster._setupWorker();
84+
85+
// Make sure it's not accidentally inherited by child processes.
86+
delete process.env.NODE_UNIQUE_ID;
8087
}
8188

82-
if (process._eval != null) {
83-
// User passed '-e' or '--eval' arguments to Node.
84-
evalScript('[eval]');
85-
} else if (process.argv[1]) {
86-
// make process.argv[1] into a full path
87-
var path = NativeModule.require('path');
88-
process.argv[1] = path.resolve(process.argv[1]);
89-
90-
// If this is a worker in cluster mode, start up the communication
91-
// channel.
92-
if (process.env.NODE_UNIQUE_ID) {
93-
var cluster = NativeModule.require('cluster');
94-
cluster._setupWorker();
95-
96-
// Make sure it's not accidentally inherited by child processes.
97-
delete process.env.NODE_UNIQUE_ID;
98-
}
89+
var Module = NativeModule.require('module');
9990

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

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

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

118-
var debugTimeout = +process.env.NODE_DEBUG_TIMEOUT || 50;
119-
setTimeout(Module.runMain, debugTimeout);
110+
} else {
111+
// Main entry point into most programs:
112+
Module.runMain();
113+
}
120114

121-
} else {
122-
// Main entry point into most programs:
123-
Module.runMain();
115+
} else {
116+
var Module = NativeModule.require('module');
117+
118+
// If -i or --interactive were passed, or stdin is a TTY.
119+
if (process._forceRepl || NativeModule.require('tty').isatty(0)) {
120+
// REPL
121+
var opts = {
122+
useGlobal: true,
123+
ignoreUndefined: false
124+
};
125+
if (parseInt(process.env['NODE_NO_READLINE'], 10)) {
126+
opts.terminal = false;
124127
}
128+
if (parseInt(process.env['NODE_DISABLE_COLORS'], 10)) {
129+
opts.useColors = false;
130+
}
131+
var repl = Module.requireRepl().start(opts);
132+
repl.on('exit', function() {
133+
process.exit();
134+
});
125135

126136
} else {
127-
var Module = NativeModule.require('module');
128-
129-
// If -i or --interactive were passed, or stdin is a TTY.
130-
if (process._forceRepl || NativeModule.require('tty').isatty(0)) {
131-
// REPL
132-
var opts = {
133-
useGlobal: true,
134-
ignoreUndefined: false
135-
};
136-
if (parseInt(process.env['NODE_NO_READLINE'], 10)) {
137-
opts.terminal = false;
138-
}
139-
if (parseInt(process.env['NODE_DISABLE_COLORS'], 10)) {
140-
opts.useColors = false;
141-
}
142-
var repl = Module.requireRepl().start(opts);
143-
repl.on('exit', function() {
144-
process.exit();
145-
});
146-
147-
} else {
148-
// Read all of stdin - execute it.
149-
process.stdin.setEncoding('utf8');
137+
// Read all of stdin - execute it.
138+
process.stdin.setEncoding('utf8');
150139

151-
var code = '';
152-
process.stdin.on('data', function(d) {
153-
code += d;
154-
});
140+
var code = '';
141+
process.stdin.on('data', function(d) {
142+
code += d;
143+
});
155144

156-
process.stdin.on('end', function() {
157-
process._eval = code;
158-
evalScript('[stdin]');
159-
});
160-
}
145+
process.stdin.on('end', function() {
146+
process._eval = code;
147+
evalScript('[stdin]');
148+
});
161149
}
162150
}
163151
}

test/fixtures/printA.js

-1
This file was deleted.

test/fixtures/printB.js

-1
This file was deleted.

test/fixtures/printC.js

-1
This file was deleted.

test/parallel/test-preload.js

-75
This file was deleted.

0 commit comments

Comments
 (0)