Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for usage with Electron renderer processes #10

Closed
wants to merge 1 commit into from

Conversation

davej
Copy link

@davej davej commented Sep 14, 2015

I'm not sure if this would be considered in-scope of the project but I added a conditional so that it works consistently with Electron.

Before this fix, if run in the Electron 'renderer' process then it would return the path for the dir containing the HTML file it is require'd on.
This is not what normally what you would want, this fix will use the app-root-path for the main process instead.

Probably not the most efficient way to implement this but it works for me.

Before this fix the Electron renderer process would return the path for the HTML file it is require'd on.
This is not what normally what you would want, this fix will use the app-root-path for the main process instead.
@inxilpro
Copy link
Owner

inxilpro commented Dec 1, 2015

Sorry for such a late reply. Can you explain the use case for needing the root path inside the renderer process?

@davej
Copy link
Author

davej commented Dec 1, 2015

The same use cases that this module has when used in Node… referencing files/paths relative to the application root with consistent results.

@inxilpro
Copy link
Owner

inxilpro commented Dec 1, 2015

Implemented it slightly different in 9eb0173 — how's that look?

@inxilpro
Copy link
Owner

inxilpro commented Dec 1, 2015

Just published with the beta tag—can you test it with npm i -S app-root-path@beta and make sure it works (I don't do Electron, so I don't have a test in place yet).

@davej
Copy link
Author

davej commented Dec 1, 2015

No, it doesn't work.
require('app-root-path').path should be '/Users/Dave/MyApp', but instead it is:

'/Users/Dave/MyApp/Users/Dave/MyApp/node_modules/app-root-path'

inxilpro added a commit that referenced this pull request Jun 17, 2016
@inxilpro
Copy link
Owner

OK, I just applied your logic, but placed it slightly differently in the resolve() function.

@inxilpro inxilpro closed this Jun 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants