Skip to content

Commit

Permalink
fix: Avoid searching for the root of the module twice
Browse files Browse the repository at this point in the history
  • Loading branch information
callumlocke authored and phated committed Nov 22, 2021
1 parent 2e1c776 commit b640c56
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ Liftoff.prototype.buildEnvironment = function (opts) {
if (!modulePath && configPath) {
// check the package.json sibling to our config to see if its `name`
// matches the module we're looking for
modulePackage = silentRequire(fileSearch('package.json', [configBase]));
var modulePackagePath = fileSearch('package.json', [configBase]);
modulePackage = silentRequire(modulePackagePath);
if (modulePackage && modulePackage.name === this.moduleName) {
// if it does, our module path is `main` inside package.json
modulePath = fileSearch(modulePackage.main||'index.js', [configBase]);
modulePath = path.join(path.dirname(modulePackagePath), modulePackage.main||'index.js');
cwd = configBase;
} else {
// clear if we just required a package for some other project
Expand Down

0 comments on commit b640c56

Please sign in to comment.