docs: make format check PowerShell-friendly#49913
docs: make format check PowerShell-friendly#49913yil337 wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR replaces the Unix-only Key findings:
Confidence Score: 2/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: scripts/check-docs-format.mjs
Line: 27-29
Comment:
**`spawn` without `shell: true` breaks on Windows for npm-installed CLIs**
`oxfmt` is an npm dependency (`"oxfmt": "0.41.0"` in `package.json`). On Windows, npm puts a `.cmd` shim into `node_modules/.bin/` (i.e., `oxfmt.cmd`), not a bare `oxfmt` executable. Node.js `spawn` without `shell: true` does **not** resolve `.cmd` extensions, so this call will throw an `ENOENT` error on Windows — the very platform this PR is intended to support.
The simplest fix is to enable the shell only on Windows:
```suggestion
const child = spawn("oxfmt", ["--check", ...files], {
stdio: "inherit",
shell: process.platform === "win32",
});
```
Alternatively, use the well-known `cross-spawn` package, which handles this transparently on all platforms.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: package.json
Line: 542
Comment:
**`format:docs` (write variant) still uses `xargs`**
This PR fixes `format:docs:check` for Windows but the sibling `format:docs` script on this line still uses the Unix-only `| xargs` pipeline. If Windows support is the goal, the write-variant may need the same treatment (e.g., a counterpart `write-docs-format.mjs`, or a shared script that accepts `--write` vs `--check`). Consider whether this is intentional or an oversight.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "docs: make format ch..." |
| const child = spawn("oxfmt", ["--check", ...files], { | ||
| stdio: "inherit", | ||
| }); |
There was a problem hiding this comment.
spawn without shell: true breaks on Windows for npm-installed CLIs
oxfmt is an npm dependency ("oxfmt": "0.41.0" in package.json). On Windows, npm puts a .cmd shim into node_modules/.bin/ (i.e., oxfmt.cmd), not a bare oxfmt executable. Node.js spawn without shell: true does not resolve .cmd extensions, so this call will throw an ENOENT error on Windows — the very platform this PR is intended to support.
The simplest fix is to enable the shell only on Windows:
| const child = spawn("oxfmt", ["--check", ...files], { | |
| stdio: "inherit", | |
| }); | |
| const child = spawn("oxfmt", ["--check", ...files], { | |
| stdio: "inherit", | |
| shell: process.platform === "win32", | |
| }); |
Alternatively, use the well-known cross-spawn package, which handles this transparently on all platforms.
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/check-docs-format.mjs
Line: 27-29
Comment:
**`spawn` without `shell: true` breaks on Windows for npm-installed CLIs**
`oxfmt` is an npm dependency (`"oxfmt": "0.41.0"` in `package.json`). On Windows, npm puts a `.cmd` shim into `node_modules/.bin/` (i.e., `oxfmt.cmd`), not a bare `oxfmt` executable. Node.js `spawn` without `shell: true` does **not** resolve `.cmd` extensions, so this call will throw an `ENOENT` error on Windows — the very platform this PR is intended to support.
The simplest fix is to enable the shell only on Windows:
```suggestion
const child = spawn("oxfmt", ["--check", ...files], {
stdio: "inherit",
shell: process.platform === "win32",
});
```
Alternatively, use the well-known `cross-spawn` package, which handles this transparently on all platforms.
How can I resolve this? If you propose a fix, please make it concise.| "format:all": "pnpm format && pnpm format:swift", | ||
| "format:check": "oxfmt --check", | ||
| "format:diff": "oxfmt --write && git --no-pager diff", | ||
| "format:docs": "git ls-files 'docs/**/*.md' 'docs/**/*.mdx' 'README.md' | xargs oxfmt --write", |
There was a problem hiding this comment.
format:docs (write variant) still uses xargs
This PR fixes format:docs:check for Windows but the sibling format:docs script on this line still uses the Unix-only | xargs pipeline. If Windows support is the goal, the write-variant may need the same treatment (e.g., a counterpart write-docs-format.mjs, or a shared script that accepts --write vs --check). Consider whether this is intentional or an oversight.
Prompt To Fix With AI
This is a comment left during a code review.
Path: package.json
Line: 542
Comment:
**`format:docs` (write variant) still uses `xargs`**
This PR fixes `format:docs:check` for Windows but the sibling `format:docs` script on this line still uses the Unix-only `| xargs` pipeline. If Windows support is the goal, the write-variant may need the same treatment (e.g., a counterpart `write-docs-format.mjs`, or a shared script that accepts `--write` vs `--check`). Consider whether this is intentional or an oversight.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0eb75e5315
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const child = spawn("oxfmt", ["--check", ...files], { | ||
| stdio: "inherit", | ||
| }); |
There was a problem hiding this comment.
Invoke oxfmt via a Windows-safe wrapper
On Windows this still will not make pnpm format:docs:check usable: spawn("oxfmt", ...) tries to launch the npm-installed formatter shim directly, but Node's child-process docs require .cmd tools to be run via shell: true/cmd.exe, and this repo already carries the same workaround in src/process/exec.ts and even scripts/test-parallel.mjs. Since oxfmt is a package dependency, Windows users get an oxfmt.cmd shim, so this new script will fail before checking any docs and the PowerShell-specific regression remains.
Useful? React with 👍 / 👎.
0eb75e5 to
86877c9
Compare
86877c9 to
a2c0ce8
Compare
|
Heads up: latest CI run fails before lint/tests because |
Summary
xargspipeline informat:docs:checkwith a cross-platform Node script that enumerates tracked docs files and calls oxfmt directlypnpm check:docswork in native PowerShell #44293Testing