Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/vite_task/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ impl<'a> Session<'a> {
// different schema versions don't share (and corrupt) one database.
let cache_path = cache_root.join(cache::cache_schema_dir_name().as_str());

envs.insert(Arc::from(OsStr::new("INIT_CWD")), Arc::from(cwd.as_path().as_os_str()));

// Prepend workspace's node_modules/.bin to PATH
let workspace_node_modules_bin = workspace_root.path.join("node_modules").join(".bin");
prepend_path_env(&mut envs, &workspace_node_modules_bin)?;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "init-cwd-test",
"private": true,
"workspaces": [
"packages/*"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "app",
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tasks": {
"print-init-cwd": {
"command": "vtt print-env INIT_CWD",
"cache": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- packages/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[[e2e]]
name = "init_cwd_points_to_invocation_cwd"
comment = """
Tasks run from their package directory, but INIT_CWD should point to the directory where vt was invoked.
"""
cwd = "packages/app/src"
steps = [["vt", "run", "print-init-cwd"]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# init_cwd_points_to_invocation_cwd

Tasks run from their package directory, but INIT_CWD should point to the directory where vt was invoked.

## `vt run print-init-cwd`

```
~/packages/app$ vtt print-env INIT_CWD
<workspace>/packages/app/src
```
1 change: 1 addition & 0 deletions crates/vite_task_graph/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ pub const DEFAULT_UNTRACKED_ENV: &[&str] = &[
// CI/CD environments
"CI",
// Node.js specific
"INIT_CWD",
"NODE_OPTIONS",
"COREPACK_*",
"NPM_CONFIG_STORE_DIR",
Expand Down