Commit 02e82d0
fix: resolve env files from project root in monorepo Vitest workspaces (#542)
* Initial plan
* fix: resolve env files from project root in monorepo vitest workspaces
When running Vitest from a monorepo root using the `projects` config,
varlock now correctly uses each child project's root directory (from
Vite's config.root) to find .env.schema and .env files, instead of
only looking in process.cwd() (the monorepo root).
Changes:
- execSyncVarlock: forward `cwd` option to execSync calls and fallback
walk-up
- vite integration: reloadConfig accepts optional `cwd` parameter
- vite plugin config hook: detect project root from config.root and
reload with correct cwd when it differs from process.cwd()
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/f2ed5ca5-a4f7-4db0-9f9e-10c8807a76cc
Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com>
* fix: address review feedback - remove unnecessary toString, use path.relative for comparison
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/f2ed5ca5-a4f7-4db0-9f9e-10c8807a76cc
Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com>
* fix: always reload with project root when it differs from cwd
When config.root differs from process.cwd(), always reload varlock
from the project root — even if the initial module-level load
succeeded. This handles monorepo setups where the root also has env
files, which would cause the initial load to succeed with the wrong
project's config.
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/eb9ac880-b592-41ee-9d3d-4b1859e8d3cf
Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com>1 parent 0ea6641 commit 02e82d0
3 files changed
Lines changed: 33 additions & 6 deletions
File tree
- .changeset
- packages
- integrations/vite/src
- varlock/src/lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
| 57 | + | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
144 | | - | |
145 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
146 | 160 | | |
| 161 | + | |
| 162 | + | |
147 | 163 | | |
| 164 | + | |
| 165 | + | |
148 | 166 | | |
149 | 167 | | |
150 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
80 | 82 | | |
| 83 | + | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| |||
0 commit comments