From ce0467639c56de19f0c9f227d86ef06b570f6790 Mon Sep 17 00:00:00 2001 From: Stan Lindsey Date: Mon, 16 Mar 2020 21:49:52 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20recursively=20search=20p?= =?UTF-8?q?arent=20folders=20for=20config=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #60 - Global Config --- lib/getConfig.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/getConfig.js b/lib/getConfig.js index 295e5997..cb753e81 100644 --- a/lib/getConfig.js +++ b/lib/getConfig.js @@ -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)) {