diff --git a/doc/api/cli.md b/doc/api/cli.md index 33882e32854..ed18c69c894 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -24,95 +24,79 @@ _For more info about `node debug`, please see the [debugger][] documentation._ ## Options -### `-v`, `--version` +### `-` -Print node's version. +Alias for stdin, analogous to the use of - in other command line utilities, +meaning that the script will be read from stdin, and the rest of the options +are passed to that script. -### `-h`, `--help` +### `--` -Print node command line options. -The output of this option is less detailed than this document. +Indicate the end of node options. Pass the rest of the arguments to the script. +If no script filename or eval/print script is supplied prior to this, then +the next argument will be used as a script filename. -### `-e`, `--eval "script"` +### `--abort-on-uncaught-exception` -Evaluate the following argument as JavaScript. The modules which are -predefined in the REPL can also be used in `script`. +Aborting instead of exiting causes a core file to be generated for post-mortem +analysis using a debugger (such as `lldb`, `gdb`, and `mdb`). -On Windows, using `cmd.exe` a single quote will not work correctly because it -only recognizes double `"` for quoting. In Powershell or Git bash, both `'` -and `"` are usable. +If this flag is passed, the behavior can still be set to not abort through +[`process.setUncaughtExceptionCaptureCallback()`][] (and through usage of the +`domain` module that uses it). -### `-p`, `--print "script"` +### `--enable-fips` -Identical to `-e` but prints the result. +Enable FIPS-compliant crypto at startup. (Requires Node.js to be built with +`./configure --openssl-fips`) -### `-c`, `--check` +### `--experimental-modules` -Syntax check the script without executing. +Enable experimental ES module support and caching modules. -### `-i`, `--interactive` +### `--experimental-vm-modules` -Opens the REPL even if stdin does not appear to be a terminal. +Enable experimental ES Module support in the `vm` module. -### `-r`, `--require module` +### `--force-fips` -Preload the specified module at startup. - -Follows `require()`'s module resolution -rules. `module` may be either a path to a file, or a node module name. +Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.) +(Same requirements as `--enable-fips`) -### `--inspect[=[host:]port]` +### `--icu-data-dir=file` -Activate inspector on host:port. Default is 127.0.0.1:9229. - -V8 inspector integration allows tools such as Chrome DevTools and IDEs to debug -and profile Node.js instances. The tools attach to Node.js instances via a -tcp port and communicate using the [Chrome Debugging Protocol][]. +Specify ICU data load path. (overrides `NODE_ICU_DATA`) ### `--inspect-brk[=[host:]port]` @@ -135,6 +119,27 @@ Useful when activating the inspector by sending the `SIGUSR1` signal. Default host is 127.0.0.1. +### `--inspect[=[host:]port]` + + +Activate inspector on host:port. Default is 127.0.0.1:9229. + +V8 inspector integration allows tools such as Chrome DevTools and IDEs to debug +and profile Node.js instances. The tools attach to Node.js instances via a +tcp port and communicate using the [Chrome Debugging Protocol][]. + + +### `--napi-modules` + + +Enable loading native modules compiled with the ABI-stable Node.js API (N-API) +(experimental). + + ### `--no-deprecation` -Print stack traces for deprecations. +Disables runtime checks for `async_hooks`. These will still be enabled +dynamically when `async_hooks` is enabled. -### `--throw-deprecation` +### `--no-warnings` -Throw errors for deprecations. +Silence all process warnings (including deprecations). + + +### `--openssl-config=file` + + +Load an OpenSSL configuration file on startup. Among other uses, this can be +used to enable FIPS-compliant crypto if Node.js is built with +`./configure --openssl-fips`. + ### `--pending-deprecation` - -Silence all process warnings (including deprecations). - -### `--abort-on-uncaught-exception` - - -Aborting instead of exiting causes a core file to be generated for post-mortem -analysis using a debugger (such as `lldb`, `gdb`, and `mdb`). - -If this flag is passed, the behavior can still be set to not abort through -[`process.setUncaughtExceptionCaptureCallback()`][] (and through usage of the -`domain` module that uses it). - -### `--trace-warnings` - - -Print stack traces for process warnings (including deprecations). - -### `--redirect-warnings=file` - - -Write process warnings to the given file instead of printing to stderr. The -file will be created if it does not exist, and will be appended to if it does. -If an error occurs while attempting to write the warning to the file, the -warning will be written to stderr instead. - -### `--trace-sync-io` - - -Prints a stack trace whenever synchronous I/O is detected after the first turn -of the event loop. - -### `--no-force-async-hooks-checks` - - -Disables runtime checks for `async_hooks`. These will still be enabled -dynamically when `async_hooks` is enabled. - -### `--trace-events-enabled` - - -Enables the collection of trace event tracing information. - -### `--trace-event-categories` - - -A comma separated list of categories that should be traced when trace event -tracing is enabled using `--trace-events-enabled`. - -### `--trace-event-file-pattern` - - -Template string specifying the filepath for the trace event data, it -supports `${rotation}` and `${pid}`. - -### `--zero-fill-buffers` - - -Automatically zero-fills all newly allocated [Buffer][] and [SlowBuffer][] -instances. - ### `--preserve-symlinks` + +Process V8 profiler output generated using the V8 option `--prof`. + + +### `--redirect-warnings=file` + + +Write process warnings to the given file instead of printing to stderr. The +file will be created if it does not exist, and will be appended to if it does. +If an error occurs while attempting to write the warning to the file, the +warning will be written to stderr instead. + + +### `--throw-deprecation` + + +Throw errors for deprecations. + + +### `--tls-cipher-list=list` + + +Specify an alternative default TLS cipher list. (Requires Node.js to be built +with crypto support. (Default)) + + +### `--trace-deprecation` + + +Print stack traces for deprecations. + + +### `--trace-event-categories` + + +A comma separated list of categories that should be traced when trace event +tracing is enabled using `--trace-events-enabled`. + + +### `--trace-event-file-pattern` + + +Template string specifying the filepath for the trace event data, it +supports `${rotation}` and `${pid}`. + + +### `--trace-events-enabled` + + +Enables the collection of trace event tracing information. + + +### `--trace-sync-io` + + +Prints a stack trace whenever synchronous I/O is detected after the first turn +of the event loop. + + +### `--trace-warnings` + + +Print stack traces for process warnings (including deprecations). + + ### `--track-heap-objects` -Process V8 profiler output generated using the V8 option `--prof`. +Use bundled Mozilla CA store as supplied by current Node.js version +or use OpenSSL's default CA store. The default store is selectable +at build-time. + +The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store +that is fixed at release time. It is identical on all supported platforms. + +Using OpenSSL store allows for external modifications of the store. For most +Linux and BSD distributions, this store is maintained by the distribution +maintainers and system administrators. OpenSSL CA store location is dependent on +configuration of the OpenSSL library but this can be altered at runtime using +environment variables. + +See `SSL_CERT_DIR` and `SSL_CERT_FILE`. ### `--v8-options` @@ -324,87 +359,107 @@ underscores (`_`). For example, `--stack-trace-limit` is equivalent to `--stack_trace_limit`. -### `--tls-cipher-list=list` + +### `--v8-pool-size=num` -Specify an alternative default TLS cipher list. (Requires Node.js to be built -with crypto support. (Default)) +Set V8's thread pool size which will be used to allocate background jobs. + +If set to `0` then V8 will choose an appropriate size of the thread pool based +on the number of online processors. + +If the value provided is larger than V8's maximum, then the largest value +will be chosen. -### `--enable-fips` +### `--zero-fill-buffers` -Enable FIPS-compliant crypto at startup. (Requires Node.js to be built with -`./configure --openssl-fips`) +Automatically zero-fills all newly allocated [Buffer][] and [SlowBuffer][] +instances. -### `--force-fips` +### `-c`, `--check` -Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.) -(Same requirements as `--enable-fips`) +Syntax check the script without executing. -### `--openssl-config=file` +### `-e`, `--eval "script"` -Load an OpenSSL configuration file on startup. Among other uses, this can be -used to enable FIPS-compliant crypto if Node.js is built with -`./configure --openssl-fips`. +Evaluate the following argument as JavaScript. The modules which are +predefined in the REPL can also be used in `script`. -### `--use-openssl-ca`, `--use-bundled-ca` +On Windows, using `cmd.exe` a single quote will not work correctly because it +only recognizes double `"` for quoting. In Powershell or Git bash, both `'` +and `"` are usable. + + +### `-h`, `--help` -Use OpenSSL's default CA store or use bundled Mozilla CA store as supplied by -current Node.js version. The default store is selectable at build-time. +Print node command line options. +The output of this option is less detailed than this document. -Using OpenSSL store allows for external modifications of the store. For most -Linux and BSD distributions, this store is maintained by the distribution -maintainers and system administrators. OpenSSL CA store location is dependent on -configuration of the OpenSSL library but this can be altered at runtime using -environment variables. -The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store -that is fixed at release time. It is identical on all supported platforms. - -See `SSL_CERT_DIR` and `SSL_CERT_FILE`. - -### `--icu-data-dir=file` +### `-i`, `--interactive` -Specify ICU data load path. (overrides `NODE_ICU_DATA`) +Opens the REPL even if stdin does not appear to be a terminal. -### `-` +### `-p`, `--print "script"` -Alias for stdin, analogous to the use of - in other command line utilities, -meaning that the script will be read from stdin, and the rest of the options -are passed to that script. +Identical to `-e` but prints the result. -### `--` +### `-r`, `--require module` -Indicate the end of node options. Pass the rest of the arguments to the script. -If no script filename or eval/print script is supplied prior to this, then -the next argument will be used as a script filename. +Preload the specified module at startup. + +Follows `require()`'s module resolution +rules. `module` may be either a path to a file, or a node module name. + + +### `-v`, `--version` + + +Print node's version. ## Environment Variables @@ -416,16 +471,6 @@ added: v0.1.32 `','`-separated list of core modules that should print debug information. -### `NODE_PATH=path[:…]` - - -`':'`-separated list of directories prefixed to the module search path. - -On Windows, this is a `';'`-separated list instead. - - ### `NODE_DISABLE_COLORS=1` + +When set, the well known "root" CAs (like VeriSign) will be extended with the +extra certificates in `file`. The file should consist of one or more trusted +certificates in PEM format. A message will be emitted (once) with +[`process.emitWarning()`][emit_warning] if the file is missing or +malformed, but any errors are otherwise ignored. + +Note that neither the well known nor extra certificates are used when the `ca` +options property is explicitly specified for a TLS or HTTPS client or server. + + ### `NODE_ICU_DATA=file` + +`':'`-separated list of directories prefixed to the module search path. + +On Windows, this is a `';'`-separated list instead. + + ### `NODE_PENDING_DEPRECATION=1` + +When set, process warnings will be emitted to the given file instead of +printing to stderr. The file will be created if it does not exist, and will be +appended to if it does. If an error occurs while attempting to write the +warning to the file, the warning will be written to stderr instead. This is +equivalent to using the `--redirect-warnings=file` command-line flag. + + ### `NODE_REPL_HISTORY=file` - -When set, the well known "root" CAs (like VeriSign) will be extended with the -extra certificates in `file`. The file should consist of one or more trusted -certificates in PEM format. A message will be emitted (once) with -[`process.emitWarning()`][emit_warning] if the file is missing or -malformed, but any errors are otherwise ignored. - -Note that neither the well known nor extra certificates are used when the `ca` -options property is explicitly specified for a TLS or HTTPS client or server. - ### `OPENSSL_CONF=file` - -When set, process warnings will be emitted to the given file instead of -printing to stderr. The file will be created if it does not exist, and will be -appended to if it does. If an error occurs while attempting to write the -warning to the file, the warning will be written to stderr instead. This is -equivalent to using the `--redirect-warnings=file` command-line flag. ### `UV_THREADPOOL_SIZE=size` diff --git a/doc/node.1 b/doc/node.1 index d543d9fa035..e1b0bf03265 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -61,46 +61,41 @@ without arguments to start a REPL. . .Sh OPTIONS .Bl -tag -width 6n -.It Fl v , Fl -version -Print node's version. +.It Sy \- +Alias for stdin, analogous to the use of - in other command-line utilities. +The executed script is read from stdin, and remaining arguments are passed to the script. . -.It Fl h , Fl -help -Print node command line options. -The output of this option is less detailed than this document. -. -.It Fl e , Fl -eval Ar string -Evaluate -.Ar string -as JavaScript. -. -.It Fl p , Fl -print Ar string -Identical to -.Fl e , -but prints the result. -. -.It Fl c , Fl -check -Check the script's syntax without executing it. -Exits with an error code if script is invalid. -. -.It Fl i , Fl -interactive -Open the REPL even if stdin does not appear to be a terminal. -. -.It Fl r , Fl -require Ar module -Preload the specified -.Ar module -at startup. -Follows `require()`'s module resolution rules. -.Ar module -may be either a path to a file, or a node module name. -. -.It Fl -inspect Ns = Ns Ar [host:]port -Activate inspector on -.Ar host:port . -Default is -.Sy 127.0.0.1:9229 . +.It Fl \- +Indicate the end of node options. +Pass the rest of the arguments to the script. .Pp -V8 Inspector integration allows attaching Chrome DevTools and IDEs to Node.js instances for debugging and profiling. -It uses the Chrome Debugging Protocol. +If no script filename or eval/print script is supplied prior to this, then +the next argument will be used as a script filename. +. +.It Fl -abort-on-uncaught-exception +Aborting instead of exiting causes a core file to be generated for analysis. +. +.It Fl -enable-fips +Enable FIPS-compliant crypto at startup. +Requires Node.js to be built with +.Sy ./configure --openssl-fips . +. +.It Fl \-experimental-modules +Enable experimental ES module support and caching modules. +. +.It Fl \-experimental-vm-modules +Enable experimental ES module support in VM module. +. +.It Fl -force-fips +Force FIPS-compliant crypto on startup +(Cannot be disabled from script code). +Same requirements as +.Fl -enable-fips . +. +.It Fl -icu-data-dir Ns = Ns Ar file +Specify ICU data load path. +Overrides +.Ev NODE_ICU_DATA . . .It Fl -inspect-brk Ns = Ns Ar [host:]port Activate inspector on @@ -112,45 +107,58 @@ Set the .Ar host:port to be used when the inspector is activated. . -.It Fl -no-deprecation -Silence deprecation warnings. -. -.It Fl -trace-deprecation -Print stack traces for deprecations. -. -.It Fl -throw-deprecation -Throw errors for deprecations. -. -.It Fl -pending-deprecation -Emit pending deprecation warnings. -. -.It Fl -no-warnings -Silence all process warnings (including deprecations). +.It Fl -inspect Ns = Ns Ar [host:]port +Activate inspector on +.Ar host:port . +Default is +.Sy 127.0.0.1:9229 . +.Pp +V8 Inspector integration allows attaching Chrome DevTools and IDEs to Node.js instances for debugging and profiling. +It uses the Chrome Debugging Protocol. . .It Fl -napi-modules Enable loading native modules compiled with the ABI-stable Node.js API (N-API) (experimental). . -.It Fl -abort-on-uncaught-exception -Aborting instead of exiting causes a core file to be generated for analysis. +.It Fl -no-deprecation +Silence deprecation warnings. . -.It Fl -trace-warnings -Print stack traces for process warnings (including deprecations). +.It Fl -no-force-async-hooks-checks +Disable runtime checks for `async_hooks`. +These will still be enabled dynamically when `async_hooks` is enabled. +. +.It Fl -no-warnings +Silence all process warnings (including deprecations). +. +.It Fl -openssl-config Ns = Ns Ar file +Load an OpenSSL configuration file on startup. +Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is built with +.Sy ./configure --openssl-fips . +. +.It Fl -pending-deprecation +Emit pending deprecation warnings. +. +.It Fl -preserve-symlinks +Instructs the module loader to preserve symbolic links when resolving and caching modules. +. +.It Fl -prof-process +Process V8 profiler output generated using the V8 option +.Fl -prof . . .It Fl -redirect-warnings Ns = Ns Ar file Write process warnings to the given .Ar file instead of printing to stderr. . -.It Fl -trace-sync-io -Print a stack trace whenever synchronous I/O is detected after the first turn of the event loop. +.It Fl -throw-deprecation +Throw errors for deprecations. . -.It Fl -no-force-async-hooks-checks -Disable runtime checks for `async_hooks`. -These will still be enabled dynamically when `async_hooks` is enabled. +.It Fl -tls-cipher-list Ns = Ns Ar list +Specify an alternative default TLS cipher list. +Requires Node.js to be built with crypto support. (Default) . -.It Fl -trace-events-enabled -Enable the collection of trace event tracing information. +.It Fl -trace-deprecation +Print stack traces for deprecations. . .It Fl -trace-event-categories Ar categories A comma-separated list of categories that should be traced when trace event tracing is enabled using @@ -160,18 +168,33 @@ A comma-separated list of categories that should be traced when trace event trac Template string specifying the filepath for the trace event data, it supports \fB${rotation}\fR and \fB${pid}\fR. . -.It Fl -zero-fill-buffers -Automatically zero-fills all newly allocated Buffer and SlowBuffer instances. +.It Fl -trace-events-enabled +Enable the collection of trace event tracing information. . -.It Fl -preserve-symlinks -Instructs the module loader to preserve symbolic links when resolving and caching modules. +.It Fl -trace-sync-io +Print a stack trace whenever synchronous I/O is detected after the first turn of the event loop. +. +.It Fl -trace-warnings +Print stack traces for process warnings (including deprecations). . .It Fl -track-heap-objects Track heap object allocations for heap snapshots. . -.It Fl -prof-process -Process V8 profiler output generated using the V8 option -.Fl -prof . +.It Fl -use-bundled\-ca, Fl -use-openssl-ca +Use bundled Mozilla CA store as supplied by current Node.js version or use OpenSSL's default CA store. +The default store is selectable at build-time. +.Pp +The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store that is fixed at release time. +It is identical on all supported platforms. +.Pp +Using OpenSSL store allows for external modifications of the store. +For most Linux and BSD distributions, this store is maintained by the distribution maintainers and system administrators. +OpenSSL CA store location is dependent on configuration of the OpenSSL library but this can be altered at runtime using environment variables. +.Pp +See +.Ev SSL_CERT_DIR +and +.Ev SSL_CERT_FILE . . .It Fl -v8-options Print V8 command-line options. @@ -188,63 +211,40 @@ Set V8's thread pool size which will be used to allocate background jobs. If set to 0 then V8 will choose an appropriate size of the thread pool based on the number of online processors. If the value provided is larger than V8's maximum, then the largest value will be chosen. . -.It Fl -tls-cipher-list Ns = Ns Ar list -Specify an alternative default TLS cipher list. -Requires Node.js to be built with crypto support. (Default) +.It Fl -zero-fill-buffers +Automatically zero-fills all newly allocated Buffer and SlowBuffer instances. . -.It Fl -enable-fips -Enable FIPS-compliant crypto at startup. -Requires Node.js to be built with -.Sy ./configure --openssl-fips . +.It Fl c , Fl -check +Check the script's syntax without executing it. +Exits with an error code if script is invalid. . -.It Fl -force-fips -Force FIPS-compliant crypto on startup -(Cannot be disabled from script code). -Same requirements as -.Fl -enable-fips . +.It Fl e , Fl -eval Ar string +Evaluate +.Ar string +as JavaScript. . -.It Fl -openssl-config Ns = Ns Ar file -Load an OpenSSL configuration file on startup. -Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is built with -.Sy ./configure --openssl-fips . +.It Fl h , Fl -help +Print node command line options. +The output of this option is less detailed than this document. . -.It Fl -use-openssl-ca , Fl -use-bundled\-ca -Use OpenSSL's default CA store or use bundled Mozilla CA store as supplied by current Node.js version. -The default store is selectable at build-time. -.Pp -Using OpenSSL store allows for external modifications of the store. -For most Linux and BSD distributions, this store is maintained by the distribution maintainers and system administrators. -OpenSSL CA store location is dependent on configuration of the OpenSSL library but this can be altered at runtime using environment variables. -.Pp -The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store that is fixed at release time. -It is identical on all supported platforms. -.Pp -See -.Ev SSL_CERT_DIR -and -.Ev SSL_CERT_FILE . +.It Fl i , Fl -interactive +Open the REPL even if stdin does not appear to be a terminal. . -.It Fl -icu-data-dir Ns = Ns Ar file -Specify ICU data load path. -Overrides -.Ev NODE_ICU_DATA . +.It Fl p , Fl -print Ar string +Identical to +.Fl e , +but prints the result. . -.It Fl \-experimental-modules -Enable experimental ES module support and caching modules. +.It Fl r , Fl -require Ar module +Preload the specified +.Ar module +at startup. +Follows `require()`'s module resolution rules. +.Ar module +may be either a path to a file, or a node module name. . -.It Fl \-experimental-vm-modules -Enable experimental ES module support in VM module. -. -.It Sy \- -Alias for stdin, analogous to the use of - in other command-line utilities. -The executed script is read from stdin, and remaining arguments are passed to the script. -. -.It Fl \- -Indicate the end of node options. -Pass the rest of the arguments to the script. -.Pp -If no script filename or eval/print script is supplied prior to this, then -the next argument will be used as a script filename. +.It Fl v , Fl -version +Print node's version. .El . .\" ===================================================================== @@ -298,6 +298,13 @@ When set to .Ar 1 , emit pending deprecation warnings. . +.It Ev NODE_REDIRECT_WARNINGS Ar file +Write process warnings to the given +.Ar file +instead of printing to stderr. +Equivalent to passing +.Fl -redirect-warnings Ar file +on command-line. .It Ev NODE_REPL_HISTORY Ar file Path to the .Ar file @@ -325,14 +332,6 @@ is enabled, this overrides and sets OpenSSL's directory containing trusted certi If .Fl -use-openssl-ca is enabled, this overrides and sets OpenSSL's file containing trusted certificates. -. -.It Ev NODE_REDIRECT_WARNINGS Ar file -Write process warnings to the given -.Ar file -instead of printing to stderr. -Equivalent to passing -.Fl -redirect-warnings Ar file -on command-line. .El . .\"===================================================================== diff --git a/src/node.cc b/src/node.cc index b5084331156..335764c3025 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3445,62 +3445,79 @@ static void PrintHelp() { " node inspect script.js [arguments]\n" "\n" "Options:\n" - " -v, --version print Node.js version\n" - " -e, --eval script evaluate script\n" - " -p, --print evaluate script and print result\n" - " -c, --check syntax check script without executing\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" - " - script read from stdin (default; " - "interactive mode if a tty)\n" + " - script read from stdin (default; \n" + " interactive mode if a tty)\n" + " -- indicate the end of node options\n" + " --abort-on-uncaught-exception\n" + " aborting instead of exiting causes a\n" + " core file to be generated for analysis\n" +#if HAVE_OPENSSL && NODE_FIPS_MODE + " --enable-fips enable FIPS crypto at startup\n" +#endif // NODE_FIPS_MODE && NODE_FIPS_MODE +#if defined(NODE_HAVE_I18N_SUPPORT) + " --experimental-modules experimental ES Module support\n" + " and caching modules\n" + " --experimental-vm-modules experimental ES Module support\n" + " in vm module\n" +#endif // defined(NODE_HAVE_I18N_SUPPORT) +#if HAVE_OPENSSL && NODE_FIPS_MODE + " --force-fips force FIPS crypto (cannot be disabled)\n" +#endif // HAVE_OPENSSL && NODE_FIPS_MODE +#if defined(NODE_HAVE_I18N_SUPPORT) + " --icu-data-dir=dir set ICU data load path to dir\n" + " (overrides NODE_ICU_DATA)\n" +#if !defined(NODE_HAVE_SMALL_ICU) + " note: linked-in ICU data is present\n" +#endif +#endif // defined(NODE_HAVE_I18N_SUPPORT) #if HAVE_INSPECTOR - " --inspect[=[host:]port] activate inspector on host:port\n" - " (default: 127.0.0.1:9229)\n" " --inspect-brk[=[host:]port]\n" " activate inspector on host:port\n" " and break at start of user script\n" " --inspect-port=[host:]port\n" " set host:port for inspector\n" -#endif - " --no-deprecation silence deprecation warnings\n" - " --trace-deprecation show stack traces on deprecations\n" - " --throw-deprecation throw an exception on deprecations\n" - " --pending-deprecation emit pending deprecation warnings\n" - " --no-warnings silence all process warnings\n" + " --inspect[=[host:]port] activate inspector on host:port\n" + " (default: 127.0.0.1:9229)\n" +#endif // HAVE_INSPECTOR " --napi-modules load N-API modules (no-op - option\n" " kept for compatibility)\n" - " --abort-on-uncaught-exception\n" - " aborting instead of exiting causes a\n" - " core file to be generated for analysis\n" - " --trace-warnings show stack traces on process warnings\n" + " --no-deprecation silence deprecation warnings\n" + " --no-force-async-hooks-checks\n" + " disable checks for async_hooks\n" + " --no-warnings silence all process warnings\n" +#if HAVE_OPENSSL + " --openssl-config=file load OpenSSL configuration from the\n" + " specified file (overrides\n" + " OPENSSL_CONF)\n" +#endif // HAVE_OPENSSL + " --pending-deprecation emit pending deprecation warnings\n" +#if defined(NODE_HAVE_I18N_SUPPORT) + " --preserve-symlinks preserve symbolic links when resolving\n" +#endif + " --prof-process process v8 profiler output generated\n" + " using --prof\n" " --redirect-warnings=file\n" " write warnings to file instead of\n" " stderr\n" - " --trace-sync-io show stack trace when use of sync IO\n" - " is detected after the first tick\n" - " --no-force-async-hooks-checks\n" - " disable checks for async_hooks\n" - " --trace-events-enabled track trace events\n" + " --throw-deprecation throw an exception on deprecations\n" +#if HAVE_OPENSSL + " --tls-cipher-list=val use an alternative default TLS cipher " + "list\n" +#endif // HAVE_OPENSSL + " --trace-deprecation show stack traces on deprecations\n" " --trace-event-categories comma separated list of trace event\n" " categories to record\n" " --trace-event-file-pattern Template string specifying the\n" " filepath for the trace-events data, it\n" " supports ${rotation} and ${pid}\n" " log-rotation id. %%2$u is the pid.\n" + " --trace-events-enabled track trace events\n" + " --trace-sync-io show stack trace when use of sync IO\n" + " is detected after the first tick\n" + " --trace-warnings show stack traces on process warnings\n" " --track-heap-objects track heap object allocations for heap " "snapshots\n" - " --prof-process process v8 profiler output generated\n" - " using --prof\n" - " --zero-fill-buffers automatically zero-fill all newly " - "allocated\n" - " Buffer and SlowBuffer instances\n" - " --v8-options print v8 command line options\n" - " --v8-pool-size=num set v8's thread pool size\n" #if HAVE_OPENSSL - " --tls-cipher-list=val use an alternative default TLS cipher " - "list\n" " --use-bundled-ca use bundled CA store" #if !defined(NODE_OPENSSL_CERT_STORE) " (default)" @@ -3510,27 +3527,23 @@ static void PrintHelp() { #if defined(NODE_OPENSSL_CERT_STORE) " (default)" #endif +#endif // HAVE_OPENSSL "\n" -#if NODE_FIPS_MODE - " --enable-fips enable FIPS crypto at startup\n" - " --force-fips force FIPS crypto (cannot be disabled)\n" -#endif /* NODE_FIPS_MODE */ - " --openssl-config=file load OpenSSL configuration from the\n" - " specified file (overrides\n" - " OPENSSL_CONF)\n" -#endif /* HAVE_OPENSSL */ -#if defined(NODE_HAVE_I18N_SUPPORT) - " --icu-data-dir=dir set ICU data load path to dir\n" - " (overrides NODE_ICU_DATA)\n" -#if !defined(NODE_HAVE_SMALL_ICU) - " note: linked-in ICU data is present\n" -#endif - " --preserve-symlinks preserve symbolic links when resolving\n" - " --experimental-modules experimental ES Module support\n" - " and caching modules\n" - " --experimental-vm-modules experimental ES Module support\n" - " in vm module\n" -#endif + " --v8-options print v8 command line options\n" + " --v8-pool-size=num set v8's thread pool size\n" + " --zero-fill-buffers automatically zero-fill all newly " + "allocated\n" + " Buffer and SlowBuffer instances\n" + " -c, --check syntax check script without executing\n" + " -e, --eval script evaluate script\n" + " -h, --help print node command line options\n" + " -i, --interactive always enter the REPL even if stdin\n" + " does not appear to be a terminal\n" + " -p, --print evaluate script and print result\n" + " -r, --require module to preload (option can be " + "repeated)\n" + " -v, --version print Node.js version\n" + "\n" "Environment variables:\n" "NODE_DEBUG ','-separated list of core modules\n" @@ -3543,12 +3556,12 @@ static void PrintHelp() { #if !defined(NODE_HAVE_SMALL_ICU) " (will extend linked-in data)\n" #endif -#endif +#endif // defined(NODE_HAVE_I18N_SUPPORT) "NODE_NO_WARNINGS set to 1 to silence process warnings\n" #if !defined(NODE_WITHOUT_NODE_OPTIONS) "NODE_OPTIONS set CLI options in the environment\n" " via a space-separated list\n" -#endif +#endif // !defined(NODE_WITHOUT_NODE_OPTIONS) #ifdef _WIN32 "NODE_PATH ';'-separated list of directories\n" #else @@ -3557,10 +3570,14 @@ static void PrintHelp() { " prefixed to the module search path\n" "NODE_PENDING_DEPRECATION set to 1 to emit pending deprecation\n" " warnings\n" - "NODE_REPL_HISTORY path to the persistent REPL history\n" - " file\n" +#if defined(NODE_HAVE_I18N_SUPPORT) + "NODE_PRESERVE_SYMLINKS set to 1 to preserve symbolic links\n" + " when resolving and caching modules\n" +#endif "NODE_REDIRECT_WARNINGS write warnings to path instead of\n" " stderr\n" + "NODE_REPL_HISTORY path to the persistent REPL history\n" + " file\n" "OPENSSL_CONF load OpenSSL configuration from file\n" "\n" "Documentation can be found at https://nodejs.org/\n"); @@ -3597,43 +3614,44 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env, static const char* whitelist[] = { // Node options, sorted in `node --help` order for ease of comparison. - "--require", "-r", + "--enable-fips", + "--experimental-modules", + "--experimental-vm-modules", + "--expose-http2", // keep as a non-op through v9.x + "--force-fips", + "--icu-data-dir", "--inspect", "--inspect-brk", "--inspect-port", - "--no-deprecation", - "--trace-deprecation", - "--throw-deprecation", - "--pending-deprecation", - "--no-warnings", - "--napi-modules", - "--expose-http2", // keep as a non-op through v9.x - "--experimental-modules", - "--experimental-vm-modules", "--loader", - "--trace-warnings", - "--redirect-warnings", - "--trace-sync-io", + "--napi-modules", + "--no-deprecation", "--no-force-async-hooks-checks", - "--trace-events-enabled", + "--no-warnings", + "--openssl-config", + "--pending-deprecation", + "--redirect-warnings", + "--require", + "--throw-deprecation", + "--tls-cipher-list", + "--trace-deprecation", "--trace-event-categories", "--trace-event-file-pattern", + "--trace-events-enabled", + "--trace-sync-io", + "--trace-warnings", "--track-heap-objects", - "--zero-fill-buffers", - "--v8-pool-size", - "--tls-cipher-list", "--use-bundled-ca", "--use-openssl-ca", - "--enable-fips", - "--force-fips", - "--openssl-config", - "--icu-data-dir", + "--v8-pool-size", + "--zero-fill-buffers", + "-r", // V8 options (define with '_', which allows '-' or '_') - "--perf_prof", - "--perf_basic_prof", "--abort_on_uncaught_exception", "--max_old_space_size", + "--perf_basic_prof", + "--perf_prof", "--stack_trace_limit", }; diff --git a/test/parallel/test-cli-node-print-help.js b/test/parallel/test-cli-node-print-help.js new file mode 100644 index 00000000000..7e21f01b69c --- /dev/null +++ b/test/parallel/test-cli-node-print-help.js @@ -0,0 +1,58 @@ +'use strict'; + +const common = require('../common'); + +// The following tests assert that the node.cc PrintHelp() function +// returns the proper set of cli options when invoked + +const assert = require('assert'); +const { exec } = require('child_process'); +let stdOut; + + +function startPrintHelpTest() { + exec(`${process.execPath} --help`, common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + stdOut = stdout; + validateNodePrintHelp(); + })); +} + +function validateNodePrintHelp() { + const config = process.config; + const HAVE_OPENSSL = common.hasCrypto; + const NODE_FIPS_MODE = common.hasFipsCrypto; + const NODE_HAVE_I18N_SUPPORT = common.hasIntl; + const HAVE_INSPECTOR = config.variables.v8_enable_inspector === 1; + + const cliHelpOptions = [ + { compileConstant: HAVE_OPENSSL, + flags: [ '--openssl-config=file', '--tls-cipher-list=val', + '--use-bundled-ca', '--use-openssl-ca' ] }, + { compileConstant: NODE_FIPS_MODE, + flags: [ '--enable-fips', '--force-fips' ] }, + { compileConstant: NODE_HAVE_I18N_SUPPORT, + flags: [ '--experimental-modules', '--experimental-vm-modules', + '--icu-data-dir=dir', '--preserve-symlinks', + 'NODE_ICU_DATA', 'NODE_PRESERVE_SYMLINKS' ] }, + { compileConstant: HAVE_INSPECTOR, + flags: [ '--inspect-brk[=[host:]port]', '--inspect-port=[host:]port', + '--inspect[=[host:]port]' ] }, + ]; + + cliHelpOptions.forEach(testForSubstring); +} + +function testForSubstring(options) { + if (options.compileConstant) { + options.flags.forEach((flag) => { + assert.strictEqual(stdOut.indexOf(flag) !== -1, true); + }); + } else { + options.flags.forEach((flag) => { + assert.strictEqual(stdOut.indexOf(flag), -1); + }); + } +} + +startPrintHelpTest();