Skip to content

Commit 942c9cc

Browse files
branchseerclaude
andcommitted
feat: warn on stderr when --filter matches no packages
Print "No packages matched the filter: <filter>" to stderr for each inclusion filter that resolves to zero packages. Exclusion filters and synthetic filters (implicit cwd, -w) are not reported. Add e2e snapshot tests covering: partial match, multiple unmatched, whitespace-split tokens, exclusion filters, glob filters, and directory filters. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ef7ca99 commit 942c9cc

13 files changed

+121
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "filter-unmatched-test",
3+
"private": true
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@test/app",
3+
"dependencies": {
4+
"@test/lib": "workspace:*"
5+
},
6+
"scripts": {
7+
"build": "print built-app"
8+
}
9+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "@test/lib",
3+
"scripts": {
4+
"build": "print built-lib"
5+
}
6+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages:
2+
- packages/*
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Tests for unmatched --filter warnings on stderr
2+
3+
# One filter matches, one doesn't → warning for the unmatched one, task still runs
4+
[[e2e]]
5+
name = "partial match warns for unmatched filter"
6+
steps = [
7+
"vp run --filter @test/app --filter nonexistent build",
8+
]
9+
10+
# Multiple unmatched alongside a match → one warning per unmatched filter
11+
[[e2e]]
12+
name = "multiple unmatched filters warn individually"
13+
steps = [
14+
"vp run --filter @test/app --filter nope1 --filter nope2 build",
15+
]
16+
17+
# Whitespace-split filter with one unmatched token
18+
[[e2e]]
19+
name = "whitespace split filter warns for unmatched token"
20+
steps = [
21+
"vp run --filter '@test/app nope' build",
22+
]
23+
24+
# Exclusion filter that matches nothing does NOT warn (only inclusions warn)
25+
[[e2e]]
26+
name = "unmatched exclusion filter does not warn"
27+
steps = [
28+
"vp run --filter @test/app --filter '!nonexistent' build",
29+
]
30+
31+
# Glob filter that matches nothing alongside a match
32+
[[e2e]]
33+
name = "unmatched glob filter warns"
34+
steps = [
35+
"vp run --filter @test/app --filter @nope/* build",
36+
]
37+
38+
# Directory filter that matches nothing
39+
[[e2e]]
40+
name = "unmatched directory filter warns"
41+
steps = [
42+
"vp run --filter @test/app --filter ./packages/nope build",
43+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run --filter @test/app --filter nope1 --filter nope2 build
6+
No packages matched the filter: nope1
7+
No packages matched the filter: nope2
8+
~/packages/app$ print built-app
9+
built-app
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run --filter @test/app --filter nonexistent build
6+
No packages matched the filter: nonexistent
7+
~/packages/app$ print built-app
8+
built-app
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run --filter @test/app --filter ./packages/nope build
6+
No packages matched the filter: ./packages/nope
7+
~/packages/app$ print built-app
8+
built-app
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run --filter @test/app --filter '!nonexistent' build
6+
~/packages/app$ print built-app
7+
built-app
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run --filter @test/app --filter @nope/* build
6+
No packages matched the filter: @nope/*
7+
~/packages/app$ print built-app
8+
built-app

0 commit comments

Comments
 (0)