Closed davej closed 8 years ago
Sorry for such a late reply. Can you explain the use case for needing the root path inside the renderer process?
The same use cases that this module has when used in Node… referencing files/paths relative to the application root with consistent results.
Implemented it slightly different in 9eb0173dd138280e027fd2b5afb687bd8ed94b43 — how's that look?
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).
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'
OK, I just applied your logic, but placed it slightly differently in the resolve()
function.
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.