Skip to content

Commit e1871b6

Browse files
committed
Allow Projects to Access Files Before Move
For project types that would like to process the files before they are moved to the output directory, but once rendering is complete. (For example, used to create a Tex output bundle based upon all the inputs used to compile the PDF).
1 parent 6f5bfbc commit e1871b6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/command/render/project.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ export async function renderProject(
299299
};
300300
};
301301

302+
let moveOutputResult: Record<string, unknown> | undefined;
302303
if (outputDirAbsolute) {
303304
// track whether we need to keep the lib dir around
304305
let keepLibsDir = false;
@@ -420,6 +421,14 @@ export async function renderProject(
420421
}
421422
});
422423

424+
// Before file move
425+
if (projType.beforeMoveOutput) {
426+
moveOutputResult = await projType.beforeMoveOutput(
427+
context,
428+
projResults.files,
429+
);
430+
}
431+
423432
sortedOperations.forEach((op) => {
424433
op.performOperation();
425434
});
@@ -608,6 +617,7 @@ export async function renderProject(
608617
context,
609618
incremental,
610619
outputFiles,
620+
moveOutputResult,
611621
);
612622
}
613623

src/project/types/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,15 @@ export interface ProjectType {
9090
incremental: boolean,
9191
) => Promise<void>;
9292
};
93+
beforeMoveOutput?: (
94+
context: ProjectContext,
95+
renderedFiles: RenderResultFile[],
96+
) => Promise<Record<string, unknown> | undefined>;
9397
postRender?: (
9498
context: ProjectContext,
9599
incremental: boolean,
96100
outputFiles: ProjectOutputFile[],
101+
moveOutputResult?: Record<string, unknown>,
97102
) => Promise<void>;
98103
formatOutputDirectory?: (
99104
format: Format,

0 commit comments

Comments
 (0)