Skip to content
Closed
Changes from 2 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
5 changes: 3 additions & 2 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ added: v0.1.27

The `process.argv` property returns a array containing the command line
arguments passed when the Node.js process was launched. The first element will
be 'node', the second element will be the name of the JavaScript file. The
be [`process.execPath()`], the second element will be the name of the JavaScript file. The
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're in here, we may as well change "name of the JavaScript file" to something like "path to the JavaScript file."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fair enough?
What say @cjihrig

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @mscdex. Also, this line should be wrapped at 80 characters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Is it a bug then that running a file named test.js using node test will lead to process.argv[1] === '/path/to/test', not /path/to/test.js?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. that's an interesting question... but I think that's ok. While there is the potential for conflicts because of the missing .js, it's not likely to have a serious impact. I guess that someone could come along and create a separate file named test after the app was started that would lead to issues but that seems like a relatively safe edge case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @cjihrig

remaining elements will be any additional command line arguments.

For example, assuming the following script for `process-args.js`:
Expand All @@ -473,7 +473,7 @@ $ node process-2.js one two=three four
Would generate the output:

```text
0: node
0: /usr/local/bin/node
1: /Users/mjr/work/node/process-2.js
2: one
3: two=three
Expand Down Expand Up @@ -1663,6 +1663,7 @@ cases:
[`process.argv`]: #process_process_argv
[`process.exit()`]: #process_process_exit_code
[`process.kill()`]: #process_process_kill_pid_signal
[`process.execPath()`]: #process_process_execPath
[`promise.catch()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch
[`require.main`]: modules.html#modules_accessing_the_main_module
[`setTimeout(fn, 0)`]: timers.html#timers_settimeout_callback_delay_arg
Expand Down