Skip to content

Commit

Permalink
Merge pull request #183 from Polymer/fix-node-10-compatibility-bug
Browse files Browse the repository at this point in the history
Prefer __dirname over module.path
  • Loading branch information
aomarks authored Aug 19, 2020
2 parents 7f32079 + 60bbf2c commit e7648fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
node_js:
- "node"
node_js: '10'
script:
- npm test
addons:
Expand Down
8 changes: 7 additions & 1 deletion src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ export interface ContainsOnDemandDependencies {
}

export const getPackageJSONPath = async(): Promise<string|null> => {
return pkgUp({cwd: module.path});
// NOTE: This used to search starting with module.path, but module.path was
// not added until Node.js v11. In order to preserve Node.js v10 compatibility
// we use __dirname instead, which should be mostly the same thing (docs are
// fuzzy on the specific differences, unfortunately).
// @see https://nodejs.org/docs/latest/api/modules.html#modules_module_path
// @see https://nodejs.org/docs/latest/api/modules.html#modules_dirname
return pkgUp({cwd: __dirname});
};

export const getPackageRoot = async(): Promise<string|null> => {
Expand Down

0 comments on commit e7648fa

Please sign in to comment.