| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6687b95 commit 978acd1
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,7 @@ To view this documentation as a manual page in your terminal, run `man node`. | |||
| 10 | 10 | ||
| 11 | 11 | ## Synopsis | |
| 12 | 12 | ||
| 13 | - `node [options] [v8 options] [script.js | -e "script"] [arguments]` | ||
| 13 | + `node [options] [v8 options] [script.js | -e "script"] [--] [arguments]` | ||
| 14 | 14 | ||
| 15 | 15 | `node debug [script.js | -e "script" | <host>:<port>] …` | |
| 16 | 16 | ||
@@ -269,6 +269,15 @@ added: v0.11.15 | |||
| 269 | 269 | ||
| 270 | 270 | Specify ICU data load path. (overrides `NODE_ICU_DATA`) | |
| 271 | 271 | ||
| 272 | + ### `--` | ||
| 273 | + <!-- YAML | ||
| 274 | + added: REPLACEME | ||
| 275 | + --> | ||
| 276 | + | ||
| 277 | + Indicate the end of node options. Pass the rest of the arguments to the script. | ||
| 278 | + If no script filename or eval/print script is supplied prior to this, then | ||
| 279 | + the next argument will be used as a script filename. | ||
| 280 | + | ||
| 272 | 281 | ## Environment Variables | |
| 273 | 282 | ||
| 274 | 283 | ### `NODE_DEBUG=module[,…]` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,7 @@ node \- Server-side JavaScript runtime | |||
| 37 | 37 | .RI [ script.js \ | | |
| 38 | 38 | .B -e | |
| 39 | 39 | .RI \&" script \&"] | |
| 40 | + .B [--] | ||
| 40 | 41 | .RI [ arguments ] | |
| 41 | 42 | .br | |
| 42 | 43 | .B node debug | |
@@ -191,6 +192,13 @@ See \fBSSL_CERT_DIR\fR and \fBSSL_CERT_FILE\fR. | |||
| 191 | 192 | .BR \-\-icu\-data\-dir =\fIfile\fR | |
| 192 | 193 | Specify ICU data load path. (overrides \fBNODE_ICU_DATA\fR) | |
| 193 | 194 | ||
| 195 | + .TP | ||
| 196 | + .BR \-\-\fR | ||
| 197 | + Indicate the end of node options. Pass the rest of the arguments to the script. | ||
| 198 | + | ||
| 199 | + If no script filename or eval/print script is supplied prior to this, then | ||
| 200 | + the next argument will be used as a script filename. | ||
| 201 | + | ||
| 194 | 202 | .SH ENVIRONMENT VARIABLES | |
| 195 | 203 | ||
| 196 | 204 | .TP | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3688,6 +3688,9 @@ static void ParseArgs(int* argc, | |||
| 3688 | 3688 | } else if (strcmp(arg, "--expose-internals") == 0 || | |
| 3689 | 3689 | strcmp(arg, "--expose_internals") == 0) { | |
| 3690 | 3690 | // consumed in js | |
| 3691 | + } else if (strcmp(arg, "--") == 0) { | ||
| 3692 | + index += 1; | ||
| 3693 | + break; | ||
| 3691 | 3694 | } else { | |
| 3692 | 3695 | // V8 option. Pass through as-is. | |
| 3693 | 3696 | new_v8_argv[new_v8_argc] = arg; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,11 @@ const child = require('child_process'); | |||
| 12 | 12 | const path = require('path'); | |
| 13 | 13 | const nodejs = `"${process.execPath}"`; | |
| 14 | 14 | ||
| 15 | + if (process.argv.length > 2) { | ||
| 16 | + console.log(process.argv.slice(2).join(' ')); | ||
| 17 | + process.exit(0); | ||
| 18 | + } | ||
| 19 | + | ||
| 15 | 20 | // Assert that nothing is written to stdout. | |
| 16 | 21 | child.exec(`${nodejs} --eval 42`, common.mustCall((err, stdout, stderr) => { | |
| 17 | 22 | assert.ifError(err); | |
@@ -133,3 +138,38 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`, | |||
| 133 | 138 | assert.strictEqual(proc.stderr, ''); | |
| 134 | 139 | assert.strictEqual(proc.stdout, 'start\nbeforeExit\nexit\n'); | |
| 135 | 140 | } | |
| 141 | + | ||
| 142 | + [ '-arg1', | ||
| 143 | + '-arg1 arg2 --arg3', | ||
| 144 | + '--', | ||
| 145 | + 'arg1 -- arg2', | ||
| 146 | + ].forEach(function(args) { | ||
| 147 | + | ||
| 148 | + // Ensure that arguments are successfully passed to eval. | ||
| 149 | + const opt = ' --eval "console.log(process.argv.slice(1).join(\' \'))"'; | ||
| 150 | + const cmd = `${nodejs}${opt} -- ${args}`; | ||
| 151 | + child.exec(cmd, common.mustCall(function(err, stdout, stderr) { | ||
| 152 | + assert.strictEqual(stdout, args + '\n'); | ||
| 153 | + assert.strictEqual(stderr, ''); | ||
| 154 | + assert.strictEqual(err, null); | ||
| 155 | + })); | ||
| 156 | + | ||
| 157 | + // Ensure that arguments are successfully passed to print. | ||
| 158 | + const popt = ' --print "process.argv.slice(1).join(\' \')"'; | ||
| 159 | + const pcmd = `${nodejs}${popt} -- ${args}`; | ||
| 160 | + child.exec(pcmd, common.mustCall(function(err, stdout, stderr) { | ||
| 161 | + assert.strictEqual(stdout, args + '\n'); | ||
| 162 | + assert.strictEqual(stderr, ''); | ||
| 163 | + assert.strictEqual(err, null); | ||
| 164 | + })); | ||
| 165 | + | ||
| 166 | + // Ensure that arguments are successfully passed to a script. | ||
| 167 | + // The first argument after '--' should be interpreted as a script | ||
| 168 | + // filename. | ||
| 169 | + const filecmd = `${nodejs} -- ${__filename} ${args}`; | ||
| 170 | + child.exec(filecmd, common.mustCall(function(err, stdout, stderr) { | ||
| 171 | + assert.strictEqual(stdout, args + '\n'); | ||
| 172 | + assert.strictEqual(stderr, ''); | ||
| 173 | + assert.strictEqual(err, null); | ||
| 174 | + })); | ||
| 175 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments