Skip to content

Commit 45fb3ae

Browse files
committed
Filter out project without code-pushup script in Turborepo
1 parent 747a511 commit 45fb3ae

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

__tests__/monorepo.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('monorepo projects detection', () => {
7171
])
7272
})
7373

74-
it('should detect projects in Turborepo', async () => {
74+
it('should detect projects in Turborepo which have code-pushup command', async () => {
7575
vol.fromJSON(
7676
{
7777
'package.json': pkgJsonContent({
@@ -96,6 +96,9 @@ describe('monorepo projects detection', () => {
9696
name: 'auth',
9797
scripts: { 'code-pushup': 'code-pushup --no-progress' }
9898
}),
99+
'e2e/package.json': pkgJsonContent({
100+
name: 'e2e'
101+
}),
99102
'frontend/backoffice/package.json': pkgJsonContent({
100103
name: 'backoffice',
101104
scripts: { 'code-pushup': 'code-pushup --no-progress' }

dist/index.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/monorepo/handlers/turbo.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ export const turboHandler: MonorepoToolHandler = {
2424
for (const handler of WORKSPACE_HANDLERS) {
2525
if (await handler.isConfigured(options)) {
2626
const projects = await handler.listProjects(options)
27-
return projects.map(({ name }) => ({
28-
name,
29-
bin: `npx turbo run ${options.task} -F ${name} --`
30-
}))
27+
return projects
28+
.filter(({ bin }) => bin.includes(`run ${options.task}`)) // must be package.json script
29+
.map(({ name }) => ({
30+
name,
31+
bin: `npx turbo run ${options.task} -F ${name} --`
32+
}))
3133
}
3234
}
3335
throw new Error(

0 commit comments

Comments
 (0)