Skip to content

Commit

Permalink
Added electron renderer check
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Dec 1, 2015
1 parent 418aea0 commit 9eb0173
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sudo: false
language: node_js
node_js:
- "5.1"
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ you want. `app-root-path` is aware of this edge-case and will strip the `/bin` a

## Change Log

### 1.1.0
### 1.2.0
- Special logic to resolve correctly when in an [electron](https://github.com/atom/electron) renderer process

### 1.1.0 (currently `app-root-path@beta`)
- Special logic to handle an edge case when used in a globally-installed CLI project
- Fixed a bug where `setPath()` did not update `require('app-root-path').path`
- Moved some logic outside of the `resolve()` function so that it's not called multiple times
Expand Down
5 changes: 5 additions & 0 deletions lib/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ module.exports = function resolve(dirname) {
return path.resolve(process.env.APP_ROOT_PATH);
}

// Defer to main process in electron
if ('type' in process && 'renderer' === process.type) {
return require('remote').require('app-root-path').resolve(dirname);
}

var resolved = path.resolve(dirname);
var alternateMethod = false;
var appRootPath = null;
Expand Down

0 comments on commit 9eb0173

Please sign in to comment.