Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function loadConfig() {
// Load .env files
async function loadEnvFiles() {
let envVars: Record<string, string> = {}
if (await Deno.stat(".env").catch(() => null)) {
if ((await Deno.stat(".env").catch(() => null))?.isFile) {
envVars = await load()
} else {
try {
Expand All @@ -96,7 +96,7 @@ async function loadEnvFiles() {
.trim()

const gitRootEnvPath = join(gitRoot, ".env")
if (await Deno.stat(gitRootEnvPath).catch(() => null)) {
if ((await Deno.stat(gitRootEnvPath).catch(() => null))?.isFile) {
envVars = await load({ envPath: gitRootEnvPath })
}
} catch {
Expand Down
15 changes: 15 additions & 0 deletions test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,21 @@ Deno.test("getOptionWithSource - process env wins over project .env and is class
}
})

Deno.test("getOptionWithSource - a .env directory is ignored, not fatal", async () => {
// Some monorepos have a `.env` directory. Loading it must not crash startup
// (previously threw IsADirectory); it is silently ignored like a missing file.
const projectDir = await Deno.makeTempDir()
const home = await Deno.makeTempDir()
try {
await Deno.mkdir(`${projectDir}/.env`)
const result = await runTeamSourceSubprocess({ cwd: projectDir, home })
assertEquals(result, null)
} finally {
await Deno.remove(projectDir, { recursive: true })
await Deno.remove(home, { recursive: true })
}
})

Deno.test("getOptionWithSource - invalid project value shadows valid global value", async () => {
// A present-but-invalid higher-precedence value must block fallback to a
// lower-precedence source, matching the pre-split spread-merge behavior.
Expand Down