-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: fix copy node executable in Windows #48624
doc: fix copy node executable in Windows #48624
Conversation
Windows where command lists all places it finds a pattern in Path. The first one is the one that executes when called. So the old code was overriding the first executable by any other match.
Review requested:
|
Found a much easier solution for copying the node executable using native node. Can probably be consolidated to all OSs.
Nice catch, thanks! Might make the docs simpler if we used the same command for both powershell and cmd. We could use the same thing for non-Windows too if we remove the |
Right, the same command can apply to both powershell and cmd. |
I'm personally okay with both. Does anyone else have a preference? If not, I think it's fine to only update the Windows commands and unify both the cmd and powershell parts into the one you suggested. |
Merged command for both PowerShell and Command Prompt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Landed in d9438cc |
Windows where command lists all places it finds a pattern in Path. The first one is the one that executes when called. So the old code was overriding the first executable by any other match. PR-URL: #48624 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Windows where command lists all places it finds a pattern in Path. The first one is the one that executes when called. So the old code was overriding the first executable by any other match. PR-URL: nodejs#48624 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Windows where command lists all places it finds a pattern in Path. The first one is the one that executes when called. So the old code was overriding the first executable by any other match. PR-URL: nodejs#48624 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
This commit does not land cleanly on |
Bug description
The Windows
where
command looks for a pattern in the %Path% and lists all matches.The first match is the one that gets executed when called.
The problem with the current code is that if
where
finds more than one match, thefor
loop will copy each of them.The result will be having the last match instead of the first one.
I encountered this when I tried to create a single executable application via GitHub Actions.
I was using a simple action configuration file:
But still, after copying the node executable using
Log showed:
And running
Got:
Fix description
node -e "require('fs').copyFileSync(process.execPath, 'hello.exe')"
Explanation:
process.execPath
gives the absolute pathname of the executable that started the Node.js processnode -e
evaluates the content inside the quotationsrequire('fs')
loads thefs
modulecopyFileSync
does the file copyThis solution should be valid for any other OS.
However, tested it on Windows only.