Skip to content

Commit

Permalink
fix(wb): getAllProjects()
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Mar 24, 2024
1 parent 6466590 commit 18fd5e2
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 5 deletions.
12 changes: 10 additions & 2 deletions packages/wb/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,16 @@ async function getAllProjects(argv: EnvReaderOptions, rootProject: Project, load
const workspace = rootProject.packageJson.workspaces;
if (!Array.isArray(workspace)) return allProjects;

const globPattern = workspace.map((ws: string) => path.join(rootProject.dirPath, ws));
const packageDirs = await globby(globPattern, { dot: true, onlyDirectories: true });
const globPattern: string[] = [];
const packageDirs: string[] = [];
for (const workspacePath of workspace.map((ws: string) => path.join(rootProject.dirPath, ws))) {
if (fs.existsSync(workspacePath)) {
packageDirs.push(workspacePath);
} else {
globPattern.push(workspacePath);
}
}
packageDirs.push(...(await globby(globPattern, { dot: true, onlyDirectories: true })));
for (const subPackageDirPath of packageDirs) {
if (!fs.existsSync(path.join(subPackageDirPath, 'package.json'))) continue;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@monorepo/sub1",
"name": "@unusual-monorepo/sub1",
"devDependencies": {
"typescript": "5.4.3"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@monorepo/sub2",
"name": "@unusual-monorepo/sub2",
"devDependencies": {
"typescript": "5.4.3"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# monorepo/sub2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@unusual-monorepo/sub3",
"devDependencies": {
"typescript": "5.4.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Hello');
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"declaration": true,
"esModuleInterop": true,
"importHelpers": false,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "dist",
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "ESNext",
"typeRoots": ["../../node_modules/@types", "../../@types", "./@types"]
},
"include": ["scripts/**/*", "src/**/*", "tests/**/*"]
}
3 changes: 2 additions & 1 deletion packages/wb/test-fixtures/unusual-monorepo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "unusual-monorepo",
"workspaces": [
"dir/subdir/packages/*"
"dir/subdir/packages/sub1",
"dir/subdir/*/sub2"
],
"devDependencies": {
"typescript": "5.4.3"
Expand Down

0 comments on commit 18fd5e2

Please sign in to comment.