(fileName: string, base?: Env)
| 566 | } |
| 567 | |
| 568 | async getLocalEnv(fileName: string, base?: Env): Promise<Env> { |
| 569 | // TODO: use the file watcher to only invalidate the env `dotfile` |
| 570 | // once a change to the `fileName` occurs |
| 571 | const filePath = join(this.cwd, fileName); |
| 572 | let env: Env = {}; |
| 573 | try { |
| 574 | const dotenv = await fs.readFile(filePath, 'utf8'); |
| 575 | output.debug(`Using local env: ${filePath}`); |
| 576 | env = parseDotenv(dotenv); |
| 577 | env = this.injectSystemValuesInDotenv(env); |
| 578 | } catch (err: unknown) { |
| 579 | if (!isErrnoException(err) || err.code !== 'ENOENT') { |
| 580 | throw err; |
| 581 | } |
| 582 | } |
| 583 | try { |
| 584 | return { |
| 585 | ...this.validateEnvConfig(fileName, base || {}, env), |
| 586 | }; |
| 587 | } catch (err) { |
| 588 | if (err instanceof MissingDotenvVarsError) { |
| 589 | output.error(err.message); |
| 590 | await this.exit(); |
| 591 | } else { |
| 592 | throw err; |
| 593 | } |
| 594 | } |
| 595 | return {}; |
| 596 | } |
| 597 | |
| 598 | clearVercelConfigPromise = () => { |
| 599 | this.getVercelConfigPromise = null; |
no test coverage detected