fix(package.json): replace rm -rf with cross-platform Node.js clean script#80
fix(package.json): replace rm -rf with cross-platform Node.js clean script#80notsoblack wants to merge 2 commits into
rm -rf with cross-platform Node.js clean script#80Conversation
- Replaces Unix-only `rm -rf` with Node.js fs.rmSync - Works on Windows PowerShell/CMD without WSL or Git Bash - Gracefully handles missing directories (ENOENT) - Returns non-zero exit code on actual errors
|
|
|
Thanks for this, @notsoblack — swapping One change before this is complete: the generated template has the same bug. "clean": "rm -rf contracts/managed .midnight-state.json .midnight-wallet-state"That script ships into the scaffolded project and runs on end users' Windows machines, so it's arguably the higher-impact case for the cross-platform goal this PR is about. Could you fold a fix for it into this PR? Heads-up so it doesn't cost you a round-trip: that template package is ESM ( import { rmSync } from "node:fs";
for (const target of ["contracts/managed", ".midnight-state.json", ".midnight-wallet-state"]) {
rmSync(target, { recursive: true, force: true });
}"clean": "node scripts/clean.mjs"(A devDependency like Two optional nits on
A couple of process items outside your code:
Really appreciate the contribution, the direction is spot on, and with the template fix it'll fully deliver the cross-platform promise. |
Bug Report & Fix
Closes #79
Problem
The
cleannpm script usesrm -rf dist test-app, which is a Unix-only shell command. On Windows (PowerShell / CMD / Windows Terminal),npm run cleanfails immediately with:This blocks Windows contributors from cleaning build artifacts and breaks CI on Windows runners.
Root Cause
The
rmbinary is not available on Windows unless the user has installed Git Bash, MSYS2, or WSL. Thecreate-mn-appCLI is meant to work cross-platform (it targets Node.js >=22), but its own build scripts are not cross-platform.Fix
Added
scripts/clean.js— A small Node.js utility that usesfs.rmSync(dir, { recursive: true, force: true }), which is fully cross-platform (Linux, macOS, Windows). It gracefully skips missing directories and exits with code 1 on actual filesystem errors.Updated
package.json— Changed"clean": "rm -rf dist test-app"to"clean": "node scripts/clean.js".Verification
rm -rf)fsImpact
This fix unblocks the
cleanworkflow for Windows developers and makes the repository's npm scripts truly cross-platform, matching the CLI's own cross-platform promises.Related
engines.nodealready requires>=22.0.0, sofs.rmSync(stabilized in Node.js 14.14.0) is safe.