Glob patterns that match no tasks now succeed silently#226
Merged
Conversation
Treat a wildcard pattern (containing *, ?, [, or {) that resolves to
zero tasks as a no-op rather than an error. This mirrors how iterating
over an empty array works, and makes it safe to write `run-p 'lint:*'`
in a new package before any lint sub-scripts exist.
Literal task names that don't exist still throw "Task not found".
Closes #149
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates task-pattern matching so glob-like patterns that match no npm scripts do not error, aligning behavior with common scaffolding workflows discussed in #149.
Changes:
- Add glob-character detection to distinguish globs vs literal task names when no tasks match.
- Skip “Task not found” errors for glob patterns that resolve to an empty match set.
- Update/add tests to expect silent success for unmatched glob patterns across entry points.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| test/pattern.js | Updates existing suite to expect silent success for an unmatched glob; adds coverage for another unmatched glob across all entry points. |
| lib/match-tasks.js | Introduces isGlob detection and uses it to suppress unknown-task errors when a glob matches nothing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace the hand-rolled GLOB_CHARS regex with picomatch.scan(pattern).isGlob so glob detection stays consistent with picomatch's own parsing rules (handles escaped chars, extglobs, etc.) - Capture stderr in the new CLI test cases and assert it's empty to confirm the silent-success behaviour produces no output
Owner
Author
|
I think this is generally a good change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
*,?,[, or{) that match no npm scripts now exit with code 0 instead of throwingTask not found.'"!test-task:**" should not match to anything'test suite to expect silent success.'"nonexistent:*" is a glob that matches nothing'test suite covering all four CLI entry points.Why
Discussed in #149. A common pattern is to scaffold standardized
package.jsonscripts up-front (e.g."lint": "run-p 'lint:*'") before any sub-scripts exist, so new packages pass CI out of the box. The current error made that impossible without a placeholder script hack.The owner's conclusion was to treat this as a small breaking change rather than add a flag — matching how array methods behave on empty inputs (no error, just no work done).
Reviewer notes
lib/match-tasks.js. AGLOB_CHARSregex detects wildcard patterns; non-glob patterns that resolve to nothing still throw.restart/envtask allowlist is unaffected.Closes #149