Skip to content

fix: Use script-shell=bash for cross-platform with-shell-commands example#12436

Merged
anthonyshew merged 2 commits intovercel:mainfrom
Goldyvaiiii:fix/with-shell-commands-windows-compat
Mar 24, 2026
Merged

fix: Use script-shell=bash for cross-platform with-shell-commands example#12436
anthonyshew merged 2 commits intovercel:mainfrom
Goldyvaiiii:fix/with-shell-commands-windows-compat

Conversation

@Goldyvaiiii
Copy link
Contributor

@Goldyvaiiii Goldyvaiiii commented Mar 24, 2026

Summary

  • Reverts the inline node -e script replacements
  • Adds .npmrc with script-shell=bash to ensure all shell commands (mkdir -p, cat, echo >) work on Windows via Git Bash

This is the same pattern Turborepo's own test suite uses (crates/turborepo/tests/common/setup.rs). It provides comprehensive cross-platform coverage without sacrificing readability or introducing fragile inline Node.js in a teaching example.

Fixes #11205.

@Goldyvaiiii Goldyvaiiii requested a review from a team as a code owner March 24, 2026 08:15
@Goldyvaiiii Goldyvaiiii requested review from tknickman and removed request for a team March 24, 2026 08:15
@turbo-orchestrator turbo-orchestrator bot added the area: examples Improvements or additions to examples label Mar 24, 2026
@vercel
Copy link
Contributor

vercel bot commented Mar 24, 2026

Someone is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@Goldyvaiiii
Copy link
Contributor Author

Replaced Unix-only shell commands (mkdir -p, cat) with cross-platform
Node.js equivalents using the built-in fs module. No new dependencies needed.
Fixes the Windows incompatibility noted in #11205.

Replace Unix-only shell commands with cross-platform Node.js equivalents:
- Replace `mkdir -p dist` with `node -e "require('fs').mkdirSync('dist',{recursive:true})"` in app-a and app-b
- Replace `cat output-file.txt` with `node -e "process.stdout.write(require('fs').readFileSync(...))"` in pkg-a and pkg-b

The with-shell-commands example uses Unix-only commands that are not available
in Windows cmd.exe, preventing users on Windows from running the example.

Fixes vercel#11205
@Goldyvaiiii Goldyvaiiii force-pushed the fix/with-shell-commands-windows-compat branch from 2e3d335 to 524a5e3 Compare March 24, 2026 08:17
…mple

Revert inline node -e replacements and instead add .npmrc with
script-shell=bash, which is the pattern used by Turborepo's own
test suite. This preserves the original readable shell commands
while ensuring they work on Windows via Git Bash.
@anthonyshew anthonyshew changed the title fix(examples): make with-shell-commands cross-platform (Windows compa… fix: Use script-shell=bash for cross-platform with-shell-commands example Mar 24, 2026
Copy link
Contributor

@anthonyshew anthonyshew left a comment

Choose a reason for hiding this comment

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

Hey, appreciate you pointing this out. We don't want to write raw Node.js scripts into these commands, when .npmrc offers a simplified way to handle this.

I've updated the PR so that the example includes a .npmrc.

@anthonyshew anthonyshew merged commit d5c2192 into vercel:main Mar 24, 2026
15 checks passed
github-actions bot added a commit that referenced this pull request Mar 25, 2026
## Release v2.8.21-canary.10

Versioned docs: https://v2-8-21-canary-10.turborepo.dev

### Changes

- release(turborepo): 2.8.21-canary.9 (#12432) (`2e2f8c3`)
- fix: Use script-shell=bash for cross-platform with-shell-commands
example (#12436) (`d5c2192`)
- docs: Add AI guide to sidebar navigation (#12438) (`021d288`)
- docs: Move `experimentalObservability` into `futureFlags` section
(#12439) (`85812cc`)
- fix: Skip Unix domain sockets and other special files during file
hashing (#12445) (`eb8f75e`)
- fix: Preserve dedupePeers and unknown pnpm lockfile settings (#12443)
(`1529b92`)

Co-authored-by: Turbobot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: examples Improvements or additions to examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

turbo watch behaves unexpectedly on Windows

2 participants