feat: allow prepared directory clean up for custom preparers

When using custom preparer for TechDocs, the `preparedDir` might
end up taking disk space. This requires all custom preparers to
implement a new method `shouldCleanPreparedDirectory` which indicates
whether the prepared directory should be cleaned after generation.

Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
Heikki Hellgren
2023-10-05 09:37:10 +03:00
parent e5b6767025
commit 344cfbcfbc
6 changed files with 31 additions and 3 deletions
@@ -60,6 +60,11 @@ export class DirectoryPreparer implements PreparerBase {
this.scmIntegrations = ScmIntegrations.fromConfig(config);
}
/** {@inheritDoc PreparerBase.shouldCleanPreparedDirectory} */
shouldCleanPreparedDirectory() {
return false;
}
/** {@inheritDoc PreparerBase.prepare} */
async prepare(
entity: Entity,
@@ -78,6 +78,11 @@ export type PreparerBase = {
* @throws `NotModifiedError` when the prepared directory has not been changed since the last build.
*/
prepare(entity: Entity, options?: PreparerOptions): Promise<PreparerResponse>;
/**
* Indicates whether the prepared directory should be cleaned after generation.
*/
shouldCleanPreparedDirectory(): boolean;
};
/**
@@ -47,6 +47,11 @@ export class UrlPreparer implements PreparerBase {
this.reader = reader;
}
/** {@inheritDoc PreparerBase.shouldCleanPreparedDirectory} */
shouldCleanPreparedDirectory() {
return true;
}
/** {@inheritDoc PreparerBase.prepare} */
async prepare(
entity: Entity,