docs: use nodejs commands for creating files on Windows (#4728)#4730
Conversation
Review Summary by QodoFix PowerShell escape character issue in Windows commands
WalkthroughsDescription• Remove trailing backtick from PowerShell commands in documentation • Trailing backtick escapes closing quote, causing malformed commands • Clarify Windows commands are specifically for PowerShell users • Fix applied consistently across all package manager sections Diagramflowchart LR
A["PowerShell Commands<br/>with trailing backtick"] -- "Remove invalid<br/>trailing backtick" --> B["Corrected Commands<br/>with proper escaping"]
C["Generic Windows<br/>user comment"] -- "Clarify target<br/>audience" --> D["PowerShell-specific<br/>user comment"]
File Changes1. docs/guides/local-setup.md
|
Code Review by Qodo
1.
|
|
The bot pointed out a compatibility problem. In PowerShell v5 command Do I need to completely resolve the encoding issue using some node command? @escapedcat For example: This works well in all platforms all shells |
There was a problem hiding this comment.
Pull request overview
Fixes Windows PowerShell command examples in the local setup guide by removing a trailing backtick that breaks quoted strings, and clarifies that the Windows-specific escaping applies to PowerShell users.
Changes:
- Remove the trailing backtick from PowerShell
echocommands that write.husky/commit-msg. - Update the inline guidance to explicitly target Windows PowerShell users (not all Windows shells).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Maybe just mention this in the docs? I'm not familiar with Windows |
|
Have a look at the copilot comments and see if they are valid, thanks! |
The PowerShell commands provided by Copilot work well. Actually, the encoding issue has also occurred once with Prettier years ago and finally it's resolved by a node command in this PR. Either PowerShell or node command can solve the problem. The former requires specifying the operating system in doc, while the latter does not, though the command may look a bit weird. |
|
Let's go with you suggestion for now |
|
I updated the PR and ran bunch of tests, shouldn't be any issues I guess. Still feels a bit odd using hex in commands, but it works nicely :D |
Yeah, looks weird, but if this is what prettier suggest I guess we're fine? Or maybe we leave the current way and add a comment that the "node" way works for all systems including Windows? In that way users have the choice? |
If there's no good solution, I'll just keep current way for linux/macos and only require the windows system to use the node command. And how about this? Just pass filename and command as parameters, longer but no hex no escape character. node -e "fs.writeFileSync(process.argv[1], process.argv[2])" <filename> <command># example 1
node -e "fs.writeFileSync(process.argv[1], process.argv[2])" '.husky/commit-msg' 'pnpm dlx commitlint --edit $1'
# example 2
node -e "fs.writeFileSync(process.argv[1], process.argv[2])" "commitlint.config.js" "export default { extends: ['@commitlint/config-conventional'] };"Or only pass one parameter node -e "fs.writeFileSync(<filename>, process.argv[1])" <command># example 1
node -e "fs.writeFileSync('.husky/commit-msg', process.argv[1])" 'pnpm dlx commitlint --edit $1'
# example 2
node -e "fs.writeFileSync('commitlint.config.js', process.argv[1])" "export default { extends: ['@commitlint/config-conventional'] };" |
|
Let's go with "one". Since the encoding/escape issues only affect Windows, I'd prefer to keep the familiar echo commands as the default and add a Windows-specific note recommending the node -e form. That way most users see the simpler snippet, and Windows users get a clear fix without hex in the command. What do you think? |
|
no problem, I'll change the doc like this |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Forget about copilot's suggestions, pretty buggy. Node has supported this since version 5. I've tested the command in various shells on Windows and it works fine. root@node18:~# fnm use 4
Using Node v4.9.1
root@node18:~# node -v
v4.9.1
root@node18:~# node -e "console.log(typeof fs.writeFileSync)"
[eval]:1
console.log(typeof fs.writeFileSync)
^
ReferenceError: fs is not defined
at [eval]:1:20
at Object.exports.runInThisContext (vm.js:54:17)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:409:26)
at node.js:648:27
at nextTickCallbackWith0Args (node.js:489:9)
at process._tickCallback (node.js:418:13)
root@node18:~# fnm use 5
Using Node v5.12.0
root@node18:~# node -v
v5.12.0
root@node18:~# node -e "console.log(typeof fs.writeFileSync)"
function
root@node18:~# node -e "console.log(global.fs === fs)"
true |
|
Thanks for being so patient! |


Description
This PR updates the doc to use node.js commands for creating files on Windows. And makes a clear distinction for the setup guide between Linux/macOS and Windows.
It brings some benefits:
Windows commands before and after:
Motivation and Context
The original doc specifically pointed out encoding issues on Windows, and instructed users to create files manually.
Commands may behave different on various shells in Powershell v5 or v7, Git Bash, Windows CMD.
This change runs a js script which consistently creates UTF-8 files across all platforms. Additionally, single-quoted strings and string concat are used in the commands to avoid special character issues.
How Has This Been Tested?
Tested on
Previous commands on windows + node v24
New commands on windows + node v24
Types of changes
Checklist: