Skip to content

Commit 48334dc

Browse files
isaacsry
authored andcommitted
Fix regression introduced in fe804d9
It breaks argv[0] on posix systems, and makes it so that npm can't determine whether node was run from an explicit location, or via "node", so the configs default improperly. If on windows, don't do this behavior. On posix, go back to the old behavior.
1 parent b6dafc1 commit 48334dc

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/node.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,15 @@
536536

537537
var cwd = process.cwd();
538538
var path = requireNative('path');
539-
540-
// Make process.argv[0] and process.argv[1] into full paths.
541-
if ('/\\'.indexOf(process.argv[0].charAt(0)) < 0
542-
&& process.argv[0].charAt(1) != ':') {
539+
var isWindows = process.platform === 'win32';
540+
541+
// Make process.argv[0] and process.argv[1] into full paths, but only
542+
// touch argv[0] if it's not a system $PATH lookup.
543+
// TODO: Make this work on Windows as well. Note that "node" might
544+
// execute cwd\node.exe, or some %PATH%\node.exe on Windows,
545+
// and that every directory has its own cwd, so d:node.exe is valid.
546+
var argv0 = process.argv[0];
547+
if (!isWindows && argv0.indexOf('/') !== -1 && argv0.charAt(0) !== '/') {
543548
process.argv[0] = path.join(cwd, process.argv[0]);
544549
}
545550

0 commit comments

Comments
 (0)