0

I've created an Electron app and build packages for Windows and MacOS using electron-packager. The app data is stored in a JSON file inside the resources folder and i'm using fs to perform file I/O tasks in the app.

What i would like to do is store the JSON file in a folder that could be accessed by both packages (Win and Mac). This way my client could use both versions of the app and the data source will be the same, thus, the data always updated.

Since i'm a Electron newbie, is there a way to "merge" both packages and share the same data file?

Ricky
  • 2,912
  • 8
  • 47
  • 74
  • Let me ask a clarifying question. Are you saying that you want to have 2 different packages (Windows and MAC) and share a file between the two running instances of your application? For example, share a text file and update it between the two apps? – unseen_damage Mar 21 '17 at 20:26
  • @unseen_damage, yes. The packages will be stored in a local network and my client would like to access the app from a PC or Mac. Since the data is stored in a JSON file, i would like to use the same file for both versions. This way the data would be the same for both packages. Is this possible? – Ricky Mar 21 '17 at 20:43

1 Answers1

0

Thanks to @kevingelion and @revln9 from the Slack Electron discussion, i was able to solve my issue. All i need to use is getAppPath() and from there go to the parent folder where the data file is located:

var app = require('electron').remote.app;
resourcePath = path.join(app.getAppPath(), '../../../db/'); //shared folder
Ricky
  • 2,912
  • 8
  • 47
  • 74