Skip to content

Commit

Permalink
feat(turbo-ignore): don’t fail on single package repos
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
tknickman committed May 20, 2024
1 parent a4ad586 commit d69a6bc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/turbo-ignore/__tests__/ignore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,4 +677,26 @@ describe("turboIgnore()", () => {

mockExec.mockRestore();
});

it("allows build if packages is missing", () => {
const mockExec = jest
.spyOn(child_process, "exec")
.mockImplementation((command, options, callback) => {
if (callback) {
return callback(
null,
'{"tasks":[]}',
"stderr"
) as unknown as ChildProcess;
}
return {} as unknown as ChildProcess;
});

turboIgnore(undefined, {
directory: "__fixtures__/app",
});

expectBuild(mockExit);
mockExec.mockRestore();
});
});
5 changes: 5 additions & 0 deletions packages/turbo-ignore/src/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ export function turboIgnore(
return continueBuild();
}
const { packages } = parsed;
if (!packages) {
info(`Detected single package repo`);
return continueBuild();
}

if (packages.length > 0) {
if (packages.length === 1) {
info(`This commit affects "${workspace}"`);
Expand Down
2 changes: 1 addition & 1 deletion packages/turbo-types/src/types/dry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export interface DryRun {
version: string;
turboVersion: string;
monorepo: boolean;
packages: Array<string>;
packages?: Array<string>;
frameworkInference: boolean;
}

0 comments on commit d69a6bc

Please sign in to comment.