electron-userland/electron-json-storage

How set path in electron app ?

zababurinsv opened this issue · 1 comments

My folder structure looked like this.


parent-folder
/docs
/storage
  /words.json
server.js
  • I build application with "electron-builder": "^22.9.1"

  • I install electron-json-storage

  • My package.json

  "build": {
    "appId": "com.org.github",
    "asar": true,
    "files": [
      "docs/",
      "lib/",
      "index.html",
      "script.js",
      "package.json",
      "main.js",
      "preload.js",
      "style.css",
      "storage/",
      "storage/words.json"
    ],
    "win": {
      "target": [
        "nsis",
        "portable"
      ],
      "icon": "build/256x256.png"
    },
    "linux": {
      "category": "TODO: fill here the category of your app",
      "icon": "build/256x256.png",
      "target": [
        "AppImage",
        "deb"
      ]
    }
  },
  • I can set folder in cwd.
 storage.setDataPath(`${process.cwd()}/storage`);

How can i setDataPath inside my application in dir storage/words.json ?

@zababurinsv I'm not sure I understand the question. Did you manage to resolve it? Can you elaborate otherwise?

How can i setDataPath inside my application in dir storage/words.json

Are you trying to set the data path to be inside the application along with the source code? If so, keep in mind that this will not play nicely in production as your application will likely be code-signed and therefore must be treated as read-only, else the signature will break.