Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit b15a973

Browse files
committed
fix(*): From "for" to "while" function findNextJsProjectRoot
1 parent 86f116d commit b15a973

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

compiler/src/clean-up.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { existsSync, writeFileSync } from 'fs';
22
import { join, dirname } from 'path';
33

4-
function findNextJsProjectRoot(startPath: string, count: number): string | null {
4+
function findNextJsProjectRoot(startPath: string): string | null {
55
let currentPath = startPath;
6-
for (let i = 1; i <= count; i++) {
6+
while (currentPath !== '/') {
77
if (
88
existsSync(join(currentPath, 'package.json')) &&
99
(existsSync(join(currentPath, 'next.config.js')) || existsSync(join(currentPath, 'next.config.mjs')))
@@ -16,8 +16,7 @@ function findNextJsProjectRoot(startPath: string, count: number): string | null
1616
}
1717

1818
export const cleanUp = async () => {
19-
const currentDir = __dirname;
20-
const projectRoot = findNextJsProjectRoot(currentDir, 5);
19+
const projectRoot = findNextJsProjectRoot(__dirname);
2120

2221
if (!projectRoot) {
2322
console.error('Next.js project root not found');

src/_internal/utils/build-in.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { join, dirname } from 'path';
66

77
function findNextJsProjectRoot(startPath: string): string | null {
88
let currentPath = startPath;
9-
for (let i = 1; i <= 6; i++) {
9+
while (currentPath !== '/') {
1010
if (
1111
existsSync(join(currentPath, 'package.json')) &&
1212
(existsSync(join(currentPath, 'next.config.js')) || existsSync(join(currentPath, 'next.config.mjs')))
@@ -19,8 +19,7 @@ function findNextJsProjectRoot(startPath: string): string | null {
1919
}
2020

2121
export const buildIn = (styleSheet: string, global?: string) => {
22-
const currentDir = __dirname;
23-
const projectRoot = findNextJsProjectRoot(currentDir);
22+
const projectRoot = findNextJsProjectRoot(__dirname);
2423

2524
if (!projectRoot) {
2625
console.error('Next.js project root not found');

0 commit comments

Comments
 (0)