fix(core): fail when an input glob matches no file
Summary
A wildcard input that matched nothing reached the compressors as input: []. With a $1 output, minify() resolved "" and wrote nothing, so a typo in a glob or an empty build directory looked like success.
enhanceSettings()
input = wildcards(requestedInput)
+ if any requested pattern contains "*" and input is now []
+ throw "No files matched input pattern: <patterns>"
The check uses *, the same test wildcards() uses to decide whether to glob.
| Input | Before | After |
|---|---|---|
"nope/**/*.js", output $1.min.js | resolves "", writes nothing | throws No files matched input pattern: nope/**/*.js |
"nope/**/*.js", output all.js | throws No content provided | throws No files matched … |
["nope/*.js", "real.js"] | works | works (unchanged) |
"missing.js" (no glob) | unchanged | unchanged |
input: [], in-memory content | unchanged | unchanged |
Evidence
- New
setup-no-match.test.ts, 6 tests: before the fix 4 fail and 2 pass, after the fix all pass. - Real runs on the merged tree produce the "After" column above.
bun run test: 72 files, 1086 tests pass. Lint, typecheck,ci-guard-type-suppressions.shpass.
Merge Danger
Door: two-way
Blast Radius: core, CLI, Action users
A build or workflow that relied on an empty glob succeeding will now fail. That is the intended fix, but the release notes should say so. Changeset: @node-minify/core patch.
Summary by cubic
Fails minify() when a wildcard input matches no file, so a typo'ed glob or empty build directory no longer looks like success. Previously an unmatched glob reached the compressors as input: [], resolved a $1 output to an empty string and wrote nothing, or failed with No content provided for a plain output; both cases now throw No files matched input pattern: <pattern>.
- Uses the same
*wildcard detection thatwildcards()uses to decide whether to glob. - Explicit empty input arrays and in-memory
contentare unaffected, as are non-glob missing files such asmissing.js. - Breaking for builds that relied on an empty glob succeeding; the changeset marks
@node-minify/coreas a patch.