Electron-builder: Proper way to get the path to extraFiles

Created on 28 Aug 2018  Â·  4Comments  Â·  Source: electron-userland/electron-builder

I am currently using the extraFiles property to bundle binaries.

That seems to work fine (at least with AppImage), but figuring out the correct path is starting to be pretty tricky, and I can only imagine it will get more difficult with other build targets.

Is there a proper way to get the path to the extraFiles that would work in both dev mode and various electron-builder targets?

question

Most helpful comment

So I can confirm it seems to work (at least on Windows portable and Linux AppImage). Here's how for reference:

prodPath = path.resolve(`${process.resourcesPath}/../bin/${executableBin}`);
devPath = path.resolve(`${__dirname}/../../bin/${executableBin}`);

Note that I had to go up a level, but that wasn't an issue for me - as long as it is consistent on all platforms.

Example

All 4 comments

For production process.resourcesPath should work https://electronjs.org/docs/api/process#processresourcespath — path.dirname(process.resourcesPath) (since you use extraFiles, and not extraResources).

But for dev no way.

Thanks, will check it out!

So I can confirm it seems to work (at least on Windows portable and Linux AppImage). Here's how for reference:

prodPath = path.resolve(`${process.resourcesPath}/../bin/${executableBin}`);
devPath = path.resolve(`${__dirname}/../../bin/${executableBin}`);

Note that I had to go up a level, but that wasn't an issue for me - as long as it is consistent on all platforms.

Example

Hey @gajop, do you actually have bin in your electron packaged app, because I can't find it in mine?

Also, for Windows, don't you have to use backslash, e.g., ath.resolve(`${process.resourcesPath}\\.\\/bin\\${executableBin}`);?

Was this page helpful?
0 / 5 - 0 ratings