electron-userland / electron-userland/electron-webpack
App name is always "Electron" in dev, very problematic for storing user data
- Dominant language
- TypeScript
- Stars
- 902
- Forks
- 168
- PR merge metrics
- No merged PRs in 30d
Description
When running in dev (`electron-webpack dev`), `app.getName()` will always be `"Electron"`. This is a big problem for persisted data because all apps will start writing to the same folder.
I tracked the problem down to [this line of code](https://github.com/electron-userland/electron-webpack/blob/ae2a2f1ab3f2671831eb08169ee1d20aa00dfbb6/packages/electron-webpack/src/dev/dev-runner.ts#L63).
https://github.com/electron-userland/electron-webpack/blob/ae2a2f1ab3f2671831eb08169ee1d20aa00dfbb6/packages/electron-webpack/src/dev/dev-runner.ts#L63
There are several resources that say you should give electron the app's folder and not the `main.js` module. This is the same issue as #61 but it looks abandoned. ([For example](https://github.com/electron/electron/issues/3391))
A potential fix would be to use:
```ts
args.push(path.join(projectDir, "dist/main"))
```
Calling `app.setName(...)` doesn't resolve this.
EDIT:
The following is a workaround:
```ts
const appName = 'My App Name';
app.setName(appName);
const appData = app.getPath('appData');
app.setPath('userData', path.join(appData, appName));
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.