kfranqueiro / electern

A cross-platform Atom/RSS feed reader built using Electron and dgrid.
MIT License
2 stars 0 forks source link

Support portable option #2

Closed kfranqueiro closed 8 years ago

kfranqueiro commented 8 years ago

This may not be feasible across all platforms, but I'm a big fan of having portable applications at least on Windows. Currently Electern is creating its data files within the userData folder as determined from Electron's app.getPath('userData').

Given that the app's code will be bundled into an asar for distribution, we'll likely need to determine the path to store files portably by determining the executable path, since otherwise it will default to attempting to store things within the asar, which isn't supported.

I'm also wondering whether it's feasible to redefine the userData folder for portability purposes, or whether it would already be too late by the time the code runs (i.e. files would already be created in the default userData location).

kfranqueiro commented 8 years ago

This should be possible - electron's docs even call out that it needs to be done before the app ready event.

In brief testing on Windows it seems to work, except that a directory will still end up created within your user's AppData folder anyway because the lockfile always gets stored there (which is deleted when the app exits).

I haven't tested other OSes yet; I suspect Mac OS X may throw a curveball due to how people normally install apps there.

kfranqueiro commented 8 years ago

Tested on Linux and Mac as well; seems to actually work on both. On OS X, app.getPath('exe') ends up pointing directly to the MacOS folder within the app, and storing the userData folder within there seems to work fine. Command-line arguments can be passed to open via --args.