Skip to content

Commit

Permalink
fix(cli-utils): Fix regression causing turbo command to reuse the `…
Browse files Browse the repository at this point in the history
…turbo` cache itself (#409)
  • Loading branch information
kitten authored Oct 4, 2024
1 parent 3730eba commit 94b24c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-dots-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gql.tada/cli-utils': patch
---

Fix `turbo` command's cache disabling override not being effective. This was a regression that meant the cached outputs would be reused during the next run of the `turbo` command.
17 changes: 7 additions & 10 deletions packages/cli-utils/src/ts/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface ProgramFactory {
createSourceFile(params: SourceFileParams, scriptKind?: ts.ScriptKind): ts.SourceFile;
createExternalFiles(exts?: readonly VirtualExtension[]): readonly ts.SourceFile[];

addSourceFile(file: SourceFileParams | ts.SourceFile, addRootName?: boolean): this;
addSourceFile(file: SourceFileParams | ts.SourceFile): this;
addMappedFile(file: SourceFileParams | ts.SourceFile, params: MappedFileParams): this;

addVirtualFiles(files: readonly ts.SourceFile[]): Promise<this>;
Expand Down Expand Up @@ -126,11 +126,11 @@ export const programFactory = (params: ProgramFactoryParams): ProgramFactory =>
return files;
},

addSourceFile(input, addRootName) {
addSourceFile(input) {
const sourceFile =
'fileName' in input ? input : factory.createSourceFile(input, ts.ScriptKind.TSX);
host.updateFile(sourceFile);
if (addRootName) rootNames.add(sourceFile.fileName);
rootNames.add(sourceFile.fileName);
return factory;
},

Expand All @@ -154,13 +154,10 @@ export const programFactory = (params: ProgramFactoryParams): ProgramFactory =>
const virtualCode = await transform(sourceFile);
if (virtualCode) {
factory
.addSourceFile(
{
fileId: virtualFileId,
sourceText: virtualCode.snapshot,
},
/*addRootName*/ true
)
.addSourceFile({
fileId: virtualFileId,
sourceText: virtualCode.snapshot,
})
.addMappedFile(sourceFile, {
mappings: virtualCode.mappings,
fileId: virtualFileId,
Expand Down

0 comments on commit 94b24c8

Please sign in to comment.