You've already forked wakapi-readme-stats
17 lines
480 B
JavaScript
17 lines
480 B
JavaScript
var child_process = require("child_process"),
|
|
resolve = require("resolve"),
|
|
options = {basedir: process.cwd(), paths: []};
|
|
|
|
module.exports = function(module) {
|
|
try {
|
|
return resolve.sync(module, options); // Attempt fast local resolve first.
|
|
} catch (error) {
|
|
if (!options.paths.length) {
|
|
options.paths.push(child_process.execSync("npm root -g").toString().trim());
|
|
return resolve.sync(module, options);
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
};
|