Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
feat: 🎸 recursively search parent folders for config file
Browse files Browse the repository at this point in the history
✅ Closes: #60 - Global Config
  • Loading branch information
StanLindsey authored and streamich committed May 16, 2020
1 parent f9573ff commit ce04676
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/getConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ const findOverrides = (root) => {
const dir = root || process.cwd();

for (const file of configFiles) {
const filename = path.join(dir, file);
const filename = path.resolve(dir, file);

if (fs.existsSync(filename)) {
if (fs.existsSync(filename) && fs.statSync(filename).isFile()) {
return require(filename);
}
}

const parent = path.resolve(dir, '..');

if (parent !== dir) {
return findOverrides(parent);
}

const pkgFilename = path.join(dir, 'package.json');

if (fs.existsSync(pkgFilename)) {
Expand Down

0 comments on commit ce04676

Please sign in to comment.