Skip to content

docs: make format check PowerShell-friendly#49913

Open
yil337 wants to merge 1 commit intoopenclaw:mainfrom
yil337:fix/powershell-docs-check
Open

docs: make format check PowerShell-friendly#49913
yil337 wants to merge 1 commit intoopenclaw:mainfrom
yil337:fix/powershell-docs-check

Conversation

@yil337
Copy link
Copy Markdown

@yil337 yil337 commented Mar 18, 2026

Summary

  • replace the Unix-only xargs pipeline in format:docs:check with a cross-platform Node script that enumerates tracked docs files and calls oxfmt directly
  • chunk file lists so Windows command-line limits aren’t hit, keeping the formatting check consistent across shells
  • fixes Make pnpm check:docs work in native PowerShell #44293

Testing

  • pnpm format:docs:check

@openclaw-barnacle openclaw-barnacle bot added scripts Repository scripts size: S labels Mar 18, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR replaces the Unix-only | xargs oxfmt --check pipeline in format:docs:check with a small Node.js script (scripts/check-docs-format.mjs) that uses git ls-files and chunks the file list to stay within Windows command-line limits. The overall approach is sound and the design is clean.

Key findings:

  • Critical: spawn without shell: true breaks on Windowsoxfmt is an npm dependency ("oxfmt": "0.41.0"). npm installs it as a .cmd shim on Windows (node_modules/.bin/oxfmt.cmd). Node.js spawn without { shell: true } does not resolve .cmd extensions, so the script will throw ENOENT on Windows and fail to run at all — the exact problem this PR is meant to fix.
  • format:docs (write variant) still uses xargs — the sibling script that writes formatted output was not updated. This may be intentional, but if Windows support is the goal it is worth addressing consistently.

Confidence Score: 2/5

  • The PR has a critical bug that prevents it from working on the very platform it targets; do not merge until the spawn shell issue is resolved.
  • The approach is conceptually correct and the chunking logic is well-implemented, but spawn("oxfmt", ...) without shell: true will throw ENOENT on Windows because npm-installed CLIs are .cmd shims. This directly breaks the primary cross-platform goal of the PR.
  • scripts/check-docs-format.mjs — specifically the spawn call in runOxfmt needs shell: process.platform === "win32" (or use cross-spawn).
Prompt To Fix All 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.

---

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..."

Comment on lines +27 to +29
const child = spawn("oxfmt", ["--check", ...files], {
stdio: "inherit",
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 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:

Suggested change
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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +27 to +29
const child = spawn("oxfmt", ["--check", ...files], {
stdio: "inherit",
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@yil337 yil337 force-pushed the fix/powershell-docs-check branch from 0eb75e5 to 86877c9 Compare March 18, 2026 16:30
@yil337 yil337 force-pushed the fix/powershell-docs-check branch from 86877c9 to a2c0ce8 Compare March 19, 2026 06:05
@yil337
Copy link
Copy Markdown
Author

yil337 commented Mar 19, 2026

Heads up: latest CI run fails before lint/tests because pnpm install can't build @tloncorp/[email protected]. The package's prepare -> npm run build step shells out to vite build (vite isn't bundled with the tarball) and then hits readonly ParameterSpec type errors, so every PR against main is blocked right now. I reproduced the same failure locally with pnpm install --force. I'm preparing a repo-level workaround while we wait on an upstream fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make pnpm check:docs work in native PowerShell

1 participant