Skip to content

🎥 Make videos programmatically with React

fix cleanup

Jonny Burger4cc97efcf044
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.ts
index 4c5b378f9e..230ac766da 100644
--- a/packages/bundler/src/bundle.ts
+++ b/packages/bundler/src/bundle.ts
@@ -87,6 +87,7 @@ export type BundleOptions = {
entryPoint: string;
onProgress?: (progress: number) => void;
ignoreRegisterRootWarning?: boolean;
+ onDirectoryCreated?: (dir: string) => void;
} & LegacyBundleOptions;
type Arguments =
@@ -166,6 +167,7 @@ export async function bundle(...args: Arguments): Promise<string> {
}
const outDir = await prepareOutDir(actualArgs?.outDir ?? null);
+ actualArgs.onDirectoryCreated?.(outDir);
// The config might use an override which might use
// `process.cwd()`. The context should always be the Remotion root.
diff --git a/packages/renderer/src/delete-directory.ts b/packages/renderer/src/delete-directory.ts
index 2aee801d4d..82ed9392bd 100644
--- a/packages/renderer/src/delete-directory.ts
+++ b/packages/renderer/src/delete-directory.ts
@@ -16,11 +16,20 @@ export const deleteDirectory = (directory: string): void => {
// This is even with the fixWinEPERMSync function being called by Node.JS.
// This is a workaround for this issue.
+ let retries = 2;
+ while (retries >= 0) {
+ try {
+ fs.rmSync(directory, {
+ maxRetries: 2,
+ recursive: true,
+ force: true,
+ retryDelay: 100,
+ });
+ } catch (err) {
+ retries--;
+ continue;
+ }
- fs.rmSync(directory, {
- maxRetries: 2,
- recursive: true,
- force: true,
- retryDelay: 100,
- });
+ break;
+ }
};