Browse Source

Use pkg-dir

pull/2/head
Luke Childs 7 years ago
parent
commit
06ebe5fc8f
  1. 4
      package.json
  2. 4
      src/index.js

4
package.json

@ -30,8 +30,8 @@
}, },
"homepage": "https://github.com/lukechilds/requireable", "homepage": "https://github.com/lukechilds/requireable",
"dependencies": { "dependencies": {
"find-root": "^1.1.0", "mock-require": "^2.0.2",
"mock-require": "^2.0.2" "pkg-dir": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "^0.19.1", "ava": "^0.19.1",

4
src/index.js

@ -1,12 +1,12 @@
'use strict'; 'use strict';
const findRoot = require('find-root'); const pkgDir = require('pkg-dir');
const mock = require('mock-require'); const mock = require('mock-require');
const pkg = { success: false }; const pkg = { success: false };
try { try {
pkg.path = findRoot(process.cwd()); pkg.path = pkgDir.sync();
pkg.name = require(pkg.path + '/package.json').name; pkg.name = require(pkg.path + '/package.json').name;
mock(pkg.name, require(pkg.path)); mock(pkg.name, require(pkg.path));
pkg.success = true; pkg.success = true;

Loading…
Cancel
Save