Skip to content

Commit

Permalink
fix: catch reading nonexistent env file error (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee authored Jan 22, 2023
1 parent 7475fce commit 82c8f33
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions shared/utils/rag-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ export const readEnv: (
config = merge(config, argv);

const envPath = path || join(cwd, 'env.yaml');
const env = readFileSync(envPath, 'utf-8');
if (!env) return config;
let env: string;
try {
readFileSync(envPath, 'utf-8');
} catch (error) {
return config;
}
if (!env!) return config;
const envObj = yaml.load(env);
// 与 config 合并
config = merge(config, envObj);
Expand Down

0 comments on commit 82c8f33

Please sign in to comment.