electron-userland / electron-prebuilt-compile

electron-prebuilt with Babel and React built-in
168 stars 56 forks source link

Application name/productName in package.json not used #32

Closed whphhg closed 7 years ago

whphhg commented 7 years ago

After switching from electron to electron-prebuilt-compile the name (or productName) in package.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.

anaisbetts commented 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?

whphhg commented 7 years ago

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.

alexstrat commented 7 years ago

@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

whphhg commented 7 years ago

@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.