Skip to content

Commit 3f17cbb

Browse files
committed
Fix .env loading
1 parent a38217d commit 3f17cbb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

options-loader/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { existsSync, readFileSync } from 'fs'
2+
import { join } from 'path'
23
import pico from 'picocolors'
34

45
export function loadOptions(spec, process, env) {
@@ -82,11 +83,14 @@ function parseValues(spec, args) {
8283
}
8384

8485
function loadEnv(file) {
85-
if (!file || !existsSync(file)) return undefined
86+
if (!file || !existsSync(file)) {
87+
file = join(process.cwd(), '.env')
88+
if (!existsSync(file)) return undefined
89+
}
8690
let result = {}
8791
let lines
8892
try {
89-
let lines = readFileSync(filePath, 'utf8').split('\n')
93+
lines = readFileSync(file, 'utf8').split('\n')
9094
} catch (error) {
9195
return undefined
9296
}

0 commit comments

Comments
 (0)