Skip to content

Commit

Permalink
works recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackshelton committed Aug 5, 2024
1 parent e3fbbf7 commit 0f5fd30
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions libs/qwikdev-astro/src/entrypoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,27 @@ export async function getQwikEntrypoints(
}

function findQwikLibraryEntrypoints(nodeModulesPath: string): string[] {
const entrypoints = [];
const packages = fs.readdirSync(nodeModulesPath);
const entrypoints: string[] = [];

for (const pkg of packages) {
const pkgPath = path.join(nodeModulesPath, pkg);
const libPath = path.join(pkgPath, "lib");
const entrypointPath = path.join(libPath, "index.qwik.mjs");
function searchDirectory(dirPath: string) {
const items = fs.readdirSync(dirPath);

if (fs.existsSync(entrypointPath)) {
entrypoints.push(entrypointPath);
for (const item of items) {
const fullPath = path.join(dirPath, item);
const stat = fs.statSync(fullPath);

if (stat.isDirectory()) {
// Skip nested node_modules to avoid redundant searches
if (item === "node_modules") {
continue;
}
searchDirectory(fullPath);
} else if (stat.isFile() && item.includes(".qwik.")) {
entrypoints.push(fullPath);
}
}
}

searchDirectory(nodeModulesPath);
return entrypoints;
}

0 comments on commit 0f5fd30

Please sign in to comment.