Skip to content

Commit 5a4a707

Browse files
branchseerclaude
andcommitted
feat: expand trailing / in input globs to /**
Input patterns like `"src/"` are now treated as `"src/**"`, matching all files recursively under that directory. This applies to both positive and negative globs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 88d719e commit 5a4a707

10 files changed

Lines changed: 142 additions & 1 deletion

File tree

crates/vite_task_bin/tests/e2e_snapshots/fixtures/inputs-cache-test/snapshots.toml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,38 @@ steps = [
201201
"vp run check-fspy-env-without-auto",
202202
]
203203

204-
# 8. Folder path as input: inputs: ["src"]
204+
# 8. Trailing slash input: inputs: ["src/"]
205+
# - Trailing `/` is expanded to `/**`, matching all files under that directory
206+
# - Direct and nested file changes trigger cache invalidation
207+
# - Files outside the directory do NOT trigger cache invalidation
208+
[[e2e]]
209+
name = "folder slash input - miss on direct and nested file changes"
210+
steps = [
211+
"vp run folder-slash-input",
212+
# Modify a direct file in src/
213+
"replace-file-content src/main.ts initial modified",
214+
# Cache miss: direct file changed
215+
"vp run folder-slash-input",
216+
# Reset and run again to re-establish cache
217+
"replace-file-content src/main.ts modified initial",
218+
"vp run folder-slash-input",
219+
# Modify a nested file in src/sub/
220+
"replace-file-content src/sub/nested.ts initial modified",
221+
# Cache miss: nested file changed
222+
"vp run folder-slash-input",
223+
]
224+
225+
[[e2e]]
226+
name = "folder slash input - hit on file outside directory"
227+
steps = [
228+
"vp run folder-slash-input",
229+
# Modify a file outside src/
230+
"replace-file-content test/main.test.ts outside modified",
231+
# Cache hit: file not under src/
232+
"vp run folder-slash-input",
233+
]
234+
235+
# 9. Folder path as input: inputs: ["src"]
205236
# - A bare directory name matches nothing (directories are not files)
206237
# - File changes inside the folder should NOT trigger cache invalidation
207238
[[e2e]]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run folder-slash-input
6+
$ print-file src/main.ts
7+
export const main = 'initial';
8+
> replace-file-content test/main.test.ts outside modified
9+
10+
> vp run folder-slash-input
11+
$ print-file src/main.tscache hit, replaying
12+
export const main = 'initial';
13+
14+
---
15+
[vp run] cache hit, <duration> saved.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run folder-slash-input
6+
$ print-file src/main.ts
7+
export const main = 'initial';
8+
> replace-file-content src/main.ts initial modified
9+
10+
> vp run folder-slash-input
11+
$ print-file src/main.tscache miss: content of input 'src/main.ts' changed, executing
12+
export const main = 'modified';
13+
> replace-file-content src/main.ts modified initial
14+
15+
> vp run folder-slash-input
16+
$ print-file src/main.tscache miss: content of input 'src/main.ts' changed, executing
17+
export const main = 'initial';
18+
> replace-file-content src/sub/nested.ts initial modified
19+
20+
> vp run folder-slash-input
21+
$ print-file src/main.tscache miss: content of input 'src/sub/nested.ts' changed, executing
22+
export const main = 'initial';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const nested = 'initial';

crates/vite_task_bin/tests/e2e_snapshots/fixtures/inputs-cache-test/vite-task.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
"command": "print-file src/main.ts",
5050
"inputs": ["src"],
5151
"cache": true
52+
},
53+
"folder-slash-input": {
54+
"command": "print-file src/main.ts",
55+
"inputs": ["src/"],
56+
"cache": true
5257
}
5358
}
5459
}

crates/vite_task_graph/src/config/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ fn resolve_glob_to_workspace_relative(
194194
package_dir: &AbsolutePath,
195195
workspace_root: &AbsolutePath,
196196
) -> Result<Str, ResolveTaskConfigError> {
197+
// A trailing `/` is shorthand for all files under that directory
198+
let expanded;
199+
let pattern = if let Some(prefix) = pattern.strip_suffix('/') {
200+
expanded = vite_str::format!("{prefix}/**");
201+
expanded.as_str()
202+
} else {
203+
pattern
204+
};
205+
197206
let glob = wax::Glob::new(pattern).map_err(|source| ResolveTaskConfigError::InvalidGlob {
198207
pattern: Str::from(pattern),
199208
source: Box::new(source),
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "test"
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Test that trailing `/` in glob patterns is expanded to `/**`
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
3+
expression: task_graph_json
4+
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/inputs-trailing-slash
5+
---
6+
[
7+
{
8+
"key": [
9+
"<workspace>/",
10+
"build"
11+
],
12+
"node": {
13+
"task_display": {
14+
"package_name": "test",
15+
"task_name": "build",
16+
"package_path": "<workspace>/"
17+
},
18+
"resolved_config": {
19+
"command": "echo build",
20+
"resolved_options": {
21+
"cwd": "<workspace>/",
22+
"cache_config": {
23+
"env_config": {
24+
"fingerprinted_envs": [],
25+
"pass_through_envs": [
26+
"<default pass-through envs>"
27+
]
28+
},
29+
"input_config": {
30+
"includes_auto": false,
31+
"positive_globs": [
32+
"src/**"
33+
],
34+
"negative_globs": [
35+
"dist/**"
36+
]
37+
}
38+
}
39+
}
40+
},
41+
"source": "TaskConfig"
42+
},
43+
"neighbors": []
44+
}
45+
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tasks": {
3+
"build": {
4+
"command": "echo build",
5+
"inputs": ["src/", "!dist/"],
6+
"cache": true
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)