Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: maximum call stack size exceeded at paths.js (findYarnLock function) #811

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions cli/src/lib/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ const shellSource = path.dirname(
)
const shellAppDirname = 'src/D2App'

const findYarnLock = (base) => {
if (base === '/') {
const findYarnLock = (base, directoryRoot) => {
if (base === directoryRoot) {
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), directoryRoot)
}

module.exports = (cwd = process.cwd()) => {
const base = path.resolve(cwd)
// Get the root path or drive based on the operating system
const rootPathByOS = path.parse(cwd).root;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer dependent on the operating system, it should work for all operating systems, so we should remove this comment and change the name to simply rootDirectory

Suggested change
// Get the root path or drive based on the operating system
const rootPathByOS = path.parse(cwd).root;
const rootDirectory = path.parse(cwd).root;

const paths = {
babelConfig: path.join(__dirname, '../../config/babel.config.js'),
configDefaultsApp: path.join(
Expand All @@ -44,7 +45,7 @@ module.exports = (cwd = process.cwd()) => {

base,
package: path.join(base, './package.json'),
yarnLock: findYarnLock(base),
yarnLock: findYarnLock(base, rootPathByOS),
dotenv: path.join(base, './.env'),
config: path.join(base, './d2.config.js'),
readme: path.join(base, './README.md'),
Expand Down
Loading