Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: electronのカレントディレクトリの変更のロジックを関数の外に出す #2569

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Hiroshiba
Copy link
Member

内容

electronのカレントディレクトリの変更を関数の外に出し、関数の副作用を分離しました。

その他

そもそもカレントディレクトリを変えるべきではないよなぁと感じたのでTODOコメント書いてみました。
TODOにすべきかは賛否両論な気がするので、↓にいろいろ考えを書いてみました。

@Hiroshiba Hiroshiba requested a review from a team as a code owner February 26, 2025 17:59
@voicevox-preview-pages
Copy link

voicevox-preview-pages bot commented Feb 26, 2025

🚀 プレビュー用ページを作成しました 🚀

更新時点でのコミットハッシュ:245a020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors the logic that changes Electron's current working directory by separating the side-effect from the utility function.

  • Renames the function from initializeAppPaths to getAppPaths to indicate it no longer includes side effects.
  • Moves the process.chdir call to a separate production-only code block.

Reviewed Changes

File Description
src/backend/electron/main.ts Refactors path initialization and delays the directory change call

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/backend/electron/main.ts:116

  • [nitpick] The new name 'getAppPaths' implies a pure function, but consider a name that more clearly indicates its purpose of computing paths without side effects, such as 'resolveAppPaths'.
function getAppPaths() {
Comment on lines +133 to +137
// 製品版はカレントディレクトリを.exeのパスにする
// TODO: ディレクトリを移動しないようにしたい
if (!isDevelopment) {
process.chdir(appDirPath);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

やっぱカレントディレクトリには依存しないほうが良いな~と思ったのでTODO書くのが良いかなと!
まあすぐ依存外すPR作る予定ですが。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant