Skip to content

Commit

Permalink
Merge pull request #152 from caorushizi/feat/webcontentsView
Browse files Browse the repository at this point in the history
fix: 🐛  .env
  • Loading branch information
caorushizi authored May 22, 2024
2 parents 172e041 + 899d3c8 commit ba0282f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/main/scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { existsSync, cpSync, rmSync } from "fs";
import dotenv from "dotenv";
import { resolve } from "path";
import consola from "consola";
import fs from "fs-extra";

export const mainResolve = (...r: string[]) => resolve(__dirname, "..", ...r);
export const rootResolve = (...r: string[]) =>
Expand All @@ -16,8 +17,8 @@ function loadEnv(path: string) {
return null;
}

const { error, parsed } = dotenv.config({ path, override: true });
if (error != null || !parsed) {
const parsed = dotenv.parse(fs.readFileSync(path));
if (!parsed) {
return null;
}

Expand All @@ -37,7 +38,12 @@ function loadDotEnv() {
}

export function loadDotEnvRuntime() {
loadDotEnv();
const env = loadDotEnv();

Object.keys(env).forEach((key) => {
if (process.env[key] != null || !env[key]) return;
process.env[key] = env[key];
});
}

export function loadDotEnvDefined() {
Expand Down

0 comments on commit ba0282f

Please sign in to comment.