MCPcopy Create free account
hub / github.com/vercel/vercel / getLocalEnv

Method getLocalEnv

packages/cli/src/util/dev/server.ts:568–596  ·  view source on GitHub ↗
(fileName: string, base?: Env)

Source from the content-addressed store, hash-verified

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;

Callers 1

_getVercelConfigMethod · 0.95

Calls 6

validateEnvConfigMethod · 0.95
exitMethod · 0.95
isErrnoExceptionFunction · 0.90
debugMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected