Skip to content

Commit

Permalink
Fix: LinuxとmacOSの配布パッケージを動作可能にする (VOICEVOX#798)
Browse files Browse the repository at this point in the history
* ビルド後はappDirPathにある.envを読みに行く

* .envのパス指定に関するコメントを追加
  • Loading branch information
PickledChair committed May 10, 2022
1 parent 4157aec commit c3d67b1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,18 @@ process.on("unhandledRejection", (reason) => {

// .envから設定をprocess.envに読み込み
const appDirPath = path.dirname(app.getPath("exe"));
dotenv.config({ override: true });

// NOTE: 開発版では、カレントディレクトリにある .env ファイルを読み込む。
// 一方、配布パッケージ版では .env ファイルが実行ファイルと同じディレクトリに配置されているが、
// Linux・macOS ではそのディレクトリはカレントディレクトリとはならないため、.env ファイルの
// パスを明示的に指定する必要がある。Windows の配布パッケージ版でもこの設定で起動できるため、
// 全 OS で共通の条件分岐とした。
if (isDevelopment) {
dotenv.config({ override: true });
} else {
const envPath = path.join(appDirPath, ".env");
dotenv.config({ path: envPath });
}

protocol.registerSchemesAsPrivileged([
{ scheme: "app", privileges: { secure: true, standard: true, stream: true } },
Expand Down

0 comments on commit c3d67b1

Please sign in to comment.