Closed whphhg closed 7 years ago
I'm actually surprised the opposite is true, it's usually the case that everything uses the name "electron" during development and only when you package it, it switches to your package ID. Maybe the electron package is doing something special?
Sorry but I wouldn't know, I've been in dev mode until now (it was always using name/productName) and just recently started the packaging process to get it ready for production. I see your point, but for example, what if you are working on, or just need to test mutliple Electron applications and two are using localStorage with conflicting item keys, it would cause you to overwrite one another and potentially cause issues. That's off the top of my head as I'm depending on localStorage for persistent GUI state.
@whphhg you can dynamically set the userData
path (the directory where app's localStorage, cookies and so on are stored) depending on the appName or environment.
This boilerplate is doing that for example: https://github.com/szwacz/electron-boilerplate/blob/master/src/background.js#L25-L31
@alexstrat thanks for sharing! That's the perfect solution, taking into account the environment as well. I've implemented it.
I'm fine with this issue being closed unless you'd like to keep it open for anyone else who trips over this small inconsistency in the names.
After switching from
electron
toelectron-prebuilt-compile
the name (or productName) inpackage.json
is not used for creating or reading from the folder in~/.config/name
, but it instead defaults to the Electron name.https://electron.atom.io/docs/api/app/#appgetname
Any ideas why this occurs? I've tried digging through the source code but so far I'm drawing a blank.
Edit: However, running the application packaged (using electron-builder) uses the correct name from package.json.