Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Ensure the Truffle Project Loader can be loaded in both development and production #1149

Merged
merged 2 commits into from
Mar 7, 2019

Conversation

mikeseese
Copy link
Contributor

@mikeseese mikeseese commented Mar 6, 2019

Fixes https://github.com/trufflesuite/ganache/issues/1141

trufflesuite/ganache@7042edd introduced a bug for production (but not development) builds. The commit changed the way Truffle projects were loaded by running a completely separate node process thats installed on the user's machine to make sure that the node that was loading the Truffle project would be the same version that the Truffle project was "compiled" against.

Unfortunately the directory structure built with asar packing in production doesn't actually exist on the disk so the location can't actually be loaded by node. First we needed to specify that the project loader gets unpacked to the disk by adding it into the build.extraFiles config in package.json. Then we needed to use electron.app.getAppPath() instead of __dirname to find where the source code is located. This folder is the base root of the repo in dev mode, but it actually points to resources/app.asar in production, which is why we needed to add a ../.. to the path to get to the root folder.

I achieved this through passing environment variables to the child. An interesting fun fact is that I originally didn't have ...process.env, but the PATH environment variable wasn't passed to the child so it couldn't find node; so if you provide options.env to the spawn, you have to make sure to provide everything that's needed (which makes sense, but was scratching my head for awhile)

Copy link
Contributor

@honestbonsai honestbonsai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants