From 22a6863c1b4a5d9c6c026c502a1b77dded318be7 Mon Sep 17 00:00:00 2001 From: Celso Octaviano De Carvalho <64174170+CelsoDeCarvalho@users.noreply.github.com> Date: Mon, 21 Aug 2023 19:41:04 +0200 Subject: [PATCH] fix: support yarn.lock discovery on non-unix (#811) Fixes an issue which manifested as "maximum call stack size exceeded at paths.js (findYarnLock function)" --- cli/src/lib/paths.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/src/lib/paths.js b/cli/src/lib/paths.js index 4f6be61ab..59aa52e6f 100644 --- a/cli/src/lib/paths.js +++ b/cli/src/lib/paths.js @@ -7,20 +7,20 @@ const shellSource = path.dirname( ) const shellAppDirname = 'src/D2App' -const findYarnLock = (base) => { - if (base === '/') { +const findYarnLock = (base, rootDirectory) => { + if (base === rootDirectory) { return null } - const yarnLock = path.join(base, './yarn.lock') if (fs.existsSync(yarnLock)) { return yarnLock } - return findYarnLock(path.dirname(base)) + return findYarnLock(path.dirname(base), rootDirectory) } module.exports = (cwd = process.cwd()) => { const base = path.resolve(cwd) + const rootDirectory = path.parse(cwd).root const paths = { babelConfig: path.join(__dirname, '../../config/babel.config.js'), configDefaultsApp: path.join( @@ -44,7 +44,7 @@ module.exports = (cwd = process.cwd()) => { base, package: path.join(base, './package.json'), - yarnLock: findYarnLock(base), + yarnLock: findYarnLock(base, rootDirectory), dotenv: path.join(base, './.env'), config: path.join(base, './d2.config.js'), readme: path.join(base, './README.md'),