Skip to content

Commit 89d1475

Browse files
committed
Add writeFileCallbacks to done method and also on host
1 parent d7c3b5e commit 89d1475

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

src/compiler/tsbuild.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ namespace ts {
242242
export type ReportEmitErrorSummary = (errorCount: number) => void;
243243

244244
export interface SolutionBuilderHostBase<T extends BuilderProgram> extends ProgramHost<T> {
245+
createDirectory?(path: string): void;
246+
/**
247+
* Should provide create directory and writeFile if done of invalidatedProjects is not invoked with
248+
* writeFileCallback
249+
*/
250+
writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void;
251+
245252
getModifiedTime(fileName: string): Date | undefined;
246253
setModifiedTime(fileName: string, date: Date): void;
247254
deleteFile(fileName: string): void;
@@ -673,7 +680,7 @@ namespace ts {
673680
/**
674681
* To dispose this project and ensure that all the necessary actions are taken and state is updated accordingly
675682
*/
676-
done(cancellationToken?: CancellationToken): ExitStatus;
683+
done(cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, customTransformers?: CustomTransformers): ExitStatus;
677684
getCompilerOptions(): CompilerOptions;
678685
getCurrentDirectory(): string;
679686
}
@@ -861,8 +868,8 @@ namespace ts {
861868
done,
862869
};
863870

864-
function done(cancellationToken?: CancellationToken) {
865-
executeSteps(Step.Done, cancellationToken);
871+
function done(cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, customTransformers?: CustomTransformers) {
872+
executeSteps(Step.Done, cancellationToken, writeFile, customTransformers);
866873
return doneInvalidatedProject(state, projectPath);
867874
}
868875

@@ -1127,7 +1134,7 @@ namespace ts {
11271134
return { emitSkipped: false, diagnostics: emitDiagnostics };
11281135
}
11291136

1130-
function executeSteps(till: Step, cancellationToken?: CancellationToken) {
1137+
function executeSteps(till: Step, cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, customTransformers?: CustomTransformers) {
11311138
while (step <= till && step < Step.Done) {
11321139
const currentStep = step;
11331140
switch (step) {
@@ -1144,11 +1151,11 @@ namespace ts {
11441151
break;
11451152

11461153
case Step.Emit:
1147-
emit(/*writeFileCallback*/ undefined, cancellationToken);
1154+
emit(writeFile, cancellationToken, customTransformers);
11481155
break;
11491156

11501157
case Step.EmitBundle:
1151-
emitBundle();
1158+
emitBundle(writeFile, customTransformers);
11521159
break;
11531160

11541161
case Step.BuildInvalidatedProjectOfBundle:

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4588,6 +4588,12 @@ declare namespace ts {
45884588
}
45894589
type ReportEmitErrorSummary = (errorCount: number) => void;
45904590
interface SolutionBuilderHostBase<T extends BuilderProgram> extends ProgramHost<T> {
4591+
createDirectory?(path: string): void;
4592+
/**
4593+
* Should provide create directory and writeFile if done of invalidatedProjects is not invoked with
4594+
* writeFileCallback
4595+
*/
4596+
writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void;
45914597
getModifiedTime(fileName: string): Date | undefined;
45924598
setModifiedTime(fileName: string, date: Date): void;
45934599
deleteFile(fileName: string): void;
@@ -4625,7 +4631,7 @@ declare namespace ts {
46254631
/**
46264632
* To dispose this project and ensure that all the necessary actions are taken and state is updated accordingly
46274633
*/
4628-
done(cancellationToken?: CancellationToken): ExitStatus;
4634+
done(cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, customTransformers?: CustomTransformers): ExitStatus;
46294635
getCompilerOptions(): CompilerOptions;
46304636
getCurrentDirectory(): string;
46314637
}

tests/baselines/reference/api/typescript.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4588,6 +4588,12 @@ declare namespace ts {
45884588
}
45894589
type ReportEmitErrorSummary = (errorCount: number) => void;
45904590
interface SolutionBuilderHostBase<T extends BuilderProgram> extends ProgramHost<T> {
4591+
createDirectory?(path: string): void;
4592+
/**
4593+
* Should provide create directory and writeFile if done of invalidatedProjects is not invoked with
4594+
* writeFileCallback
4595+
*/
4596+
writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void;
45914597
getModifiedTime(fileName: string): Date | undefined;
45924598
setModifiedTime(fileName: string, date: Date): void;
45934599
deleteFile(fileName: string): void;
@@ -4625,7 +4631,7 @@ declare namespace ts {
46254631
/**
46264632
* To dispose this project and ensure that all the necessary actions are taken and state is updated accordingly
46274633
*/
4628-
done(cancellationToken?: CancellationToken): ExitStatus;
4634+
done(cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, customTransformers?: CustomTransformers): ExitStatus;
46294635
getCompilerOptions(): CompilerOptions;
46304636
getCurrentDirectory(): string;
46314637
}

0 commit comments

Comments
 (0)