Browse Source

Use `pkg-dir`

It makes the code slightly simpler and it’s by me.

https://github.com/sindresorhus/pkg-dir
pull/2/head
Sindre Sorhus 7 years ago
parent
commit
ed46a00d5e
  1. 2
      package.json
  2. 5
      src/index.js

2
package.json

@ -28,7 +28,7 @@
},
"homepage": "https://github.com/lukechilds/get-root-module",
"dependencies": {
"find-root": "^1.1.0"
"pkg-dir": "^2.0.0"
},
"devDependencies": {
"ava": "^0.19.1",

5
src/index.js

@ -1,10 +1,9 @@
'use strict';
const findRoot = require('find-root');
const pkgDir = require('pkg-dir');
try {
const modulePath = findRoot(process.cwd());
module.exports = require(modulePath);
module.exports = require(pkgDir.sync());
} catch (err) {
module.exports = undefined;
}

Loading…
Cancel
Save