Skip to content

Commit 1439516

Browse files
committed
fix(plan): use task's cwd for synthetic requests instead of context cwd
1 parent b0067a9 commit 1439516

8 files changed

Lines changed: 194 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"scripts": {
3+
"lint": "vite run a#lint"
4+
}
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "a",
3+
"scripts": {
4+
"lint": "vite lint"
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[[plan]]
2+
name = "synthetic-in-subpackage"
3+
args = ["run", "lint"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
source: crates/vite_task_bin/tests/test_snapshots/main.rs
3+
expression: "&plan_json"
4+
input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/synthetic-in-subpackage
5+
---
6+
{
7+
"root_node": {
8+
"Expanded": [
9+
{
10+
"key": [
11+
"<workspace>/",
12+
"lint"
13+
],
14+
"node": {
15+
"task_display": {
16+
"package_name": "",
17+
"task_name": "lint",
18+
"package_path": "<workspace>/"
19+
},
20+
"items": [
21+
{
22+
"execution_item_display": {
23+
"task_display": {
24+
"package_name": "",
25+
"task_name": "lint",
26+
"package_path": "<workspace>/"
27+
},
28+
"command": "vite run a#lint",
29+
"and_item_index": null,
30+
"cwd": "<workspace>/"
31+
},
32+
"kind": {
33+
"Expanded": [
34+
{
35+
"key": [
36+
"<workspace>/packages/a",
37+
"lint"
38+
],
39+
"node": {
40+
"task_display": {
41+
"package_name": "a",
42+
"task_name": "lint",
43+
"package_path": "<workspace>/packages/a"
44+
},
45+
"items": [
46+
{
47+
"execution_item_display": {
48+
"task_display": {
49+
"package_name": "a",
50+
"task_name": "lint",
51+
"package_path": "<workspace>/packages/a"
52+
},
53+
"command": "vite lint",
54+
"and_item_index": null,
55+
"cwd": "<workspace>/packages/a"
56+
},
57+
"kind": {
58+
"Leaf": {
59+
"Spawn": {
60+
"cache_metadata": {
61+
"spawn_fingerprint": {
62+
"cwd": "packages/a",
63+
"program_fingerprint": {
64+
"OutsideWorkspace": {
65+
"program_name": "oxlint"
66+
}
67+
},
68+
"args": [],
69+
"env_fingerprints": {
70+
"fingerprinted_envs": {},
71+
"pass_through_env_config": [
72+
"<default pass-through envs>"
73+
]
74+
},
75+
"fingerprint_ignores": null
76+
},
77+
"execution_cache_key": {
78+
"kind": {
79+
"UserTask": {
80+
"task_name": "lint",
81+
"and_item_index": 0,
82+
"extra_args": []
83+
}
84+
},
85+
"origin_path": "packages/a"
86+
}
87+
},
88+
"spawn_command": {
89+
"program_path": "<manifest_dir>/test_bins/node_modules/.bin/oxlint",
90+
"args": [],
91+
"all_envs": {
92+
"NO_COLOR": "1",
93+
"PATH": "<workspace>/packages/a/node_modules/.bin:<workspace>/node_modules/.bin:<manifest_dir>/test_bins/node_modules/.bin"
94+
},
95+
"cwd": "<workspace>/packages/a"
96+
}
97+
}
98+
}
99+
}
100+
}
101+
]
102+
},
103+
"neighbors": []
104+
}
105+
]
106+
}
107+
}
108+
]
109+
},
110+
"neighbors": []
111+
}
112+
]
113+
}
114+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
source: crates/vite_task_bin/tests/test_snapshots/main.rs
3+
expression: task_graph_json
4+
input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/synthetic-in-subpackage
5+
---
6+
[
7+
{
8+
"key": [
9+
"<workspace>/",
10+
"lint"
11+
],
12+
"node": {
13+
"task_display": {
14+
"package_name": "",
15+
"task_name": "lint",
16+
"package_path": "<workspace>/"
17+
},
18+
"resolved_config": {
19+
"command": "vite run a#lint",
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+
}
30+
}
31+
}
32+
},
33+
"neighbors": []
34+
},
35+
{
36+
"key": [
37+
"<workspace>/packages/a",
38+
"lint"
39+
],
40+
"node": {
41+
"task_display": {
42+
"package_name": "a",
43+
"task_name": "lint",
44+
"package_path": "<workspace>/packages/a"
45+
},
46+
"resolved_config": {
47+
"command": "vite lint",
48+
"resolved_options": {
49+
"cwd": "<workspace>/packages/a",
50+
"cache_config": {
51+
"env_config": {
52+
"fingerprinted_envs": [],
53+
"pass_through_envs": [
54+
"<default pass-through envs>"
55+
]
56+
}
57+
}
58+
}
59+
}
60+
},
61+
"neighbors": []
62+
}
63+
]

crates/vite_task_plan/src/context.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ impl<'a> PlanContext<'a> {
9595
}
9696
}
9797

98-
pub fn cwd(&self) -> &Arc<AbsolutePath> {
99-
&self.cwd
100-
}
101-
10298
pub fn envs(&self) -> &HashMap<Arc<OsStr>, Arc<OsStr>> {
10399
&self.envs
104100
}

crates/vite_task_plan/src/plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async fn plan_task_as_execution_node(
189189
&and_item.envs,
190190
synthetic_plan_request,
191191
Some(task_execution_cache_key),
192-
context.cwd(),
192+
&cwd,
193193
)
194194
.with_plan_context(&context)?;
195195
ExecutionItemKind::Leaf(LeafExecutionKind::Spawn(spawn_execution))

0 commit comments

Comments
 (0)