You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build: replace fs-extra, node-watch, meow and rimraf with Node built-ins (#992)
* build: replace fs-extra, node-watch, meow and rimraf with Node builtins
These build scripts predate much of what is now in the Node standard
library. On Node 24 each maps to a builtin: fs-extra to fs.cpSync/rmSync/
mkdirSync recursive, rimraf to fs.rmSync plus fs.globSync for the one
--glob case, meow to util.parseArgs, and node-watch to fs.watch recursive
(which works on Linux since Node 19, and the watched src dir is small).
shx stays for now: its only use is the update-ufuzzy script, which goes
away together with the vendored file in the uFuzzy build-copy change, so
that removal lives there rather than here.
Note: AI-assisted (Claude Code). Manually verified by running yarn clean and a from-scratch yarn build so every rewritten script executed, checking fs.globSync('*.lock') matches and removes the right files, and confirming Node 19+ recursive watch on Linux before dropping node-watch.
* fix: run rm.js from the package root, drop the ignored copySync arg
The conda-lock and extract scripts cd into a subdir first and then called
node scripts/rm.js, but that path only resolves from the repo root, so the
removal failed with a module-not-found once the cwd changed. npm and yarn
always start a run-script at the package root, so the natural fix is to do
the removal there against a root-relative target and let the later cd handle
only conda-lock and tar, which genuinely need the subdir. This avoids a
../scripts/rm.js form that would recouple the path to the cd depth.
copySync already hardcodes { recursive: true } in its definition, so the
third argument passed at the copy-extras call site was silently ignored;
removing it keeps the recursive copy and drops the misleading option.
Note: AI-assisted (Claude Code). Manually verified: rm.js from root cwd with
a subdir glob and a glob-miss both remove the right paths and exit 0;
copySync copies a nested tree; type-check, 443 unit tests and yarn build all
pass on the merged branch.
* test: cover scripts/rm.js, the native rimraf replacement
rm.js was the one piece of new logic in this PR with no coverage: glob
detection, glob expansion, recursive removal and missing-path tolerance all
lived only in the build/conda npm scripts, which the installer CI exercises
end to end but which nothing pins at the unit level.
Expose an rm(args) function and keep the CLI behavior behind a
require.main === module guard so the same file can be imported by the test
and still run as node scripts/rm.js. The test uses a real tmpdir and absolute
glob patterns so it does not depend on cwd (fs.globSync resolves relative
patterns against process.cwd, and chdir is unavailable in worker threads).
Note: AI-assisted (Claude Code). Manually verified: the 6 cases pass; mutation
checks confirm they are not tautological (recursive:false and force:false make
three of them fail, dropping the glob branch fails the glob case); the CLI form
still removes via argv after the refactor; type-check, 449 unit tests and yarn
build pass.
* style: single-line the fs import in rm.test.ts for prettier
The multi-line import tripped prettier:check (it fits on one line under the
repo width), which failed the Lint step. No behavior change.
Note: AI-assisted (Claude Code). Manually verified: prettier:check and
eslint:check both clean on the full tree.
---------
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
"compress_env_installer:osx": "rimraf ./env_installer/jlab_server.tar.gz && cd ./env_installer/jlab_server_extracted && tar -czf ../jlab_server.tar.gz . && cd -",
45
+
"compress_env_installer:osx": "node scripts/rm.js ./env_installer/jlab_server.tar.gz && cd ./env_installer/jlab_server_extracted && tar -czf ../jlab_server.tar.gz . && cd -",
0 commit comments