🎥 Make videos programmatically with React
fix lambda
Jonny Burger961f255cf3d8
diff --git a/packages/lambda/src/bundle-lambda.ts b/packages/lambda/src/bundle-lambda.tsindex 4758e7f79f..896cff4c06 100644--- a/packages/lambda/src/bundle-lambda.ts+++ b/packages/lambda/src/bundle-lambda.ts@@ -10,7 +10,7 @@ export const bundleLambda = async (type: 'render') => {});const outfile = path.join(outdir, 'index.js');- fs.rmdirSync(outdir, {recursive: true});+ (fs.rmSync ?? fs.rmdirSync)(outdir, {recursive: true});fs.mkdirSync(outdir, {recursive: true});const template = path.join(__dirname, '..', 'src', 'functions', 'index.ts');diff --git a/packages/lambda/src/concat-videos.ts b/packages/lambda/src/concat-videos.tsindex e88ec6ea6c..94968e1ea2 100644--- a/packages/lambda/src/concat-videos.ts+++ b/packages/lambda/src/concat-videos.ts@@ -1,4 +1,3 @@-import {CliInternals} from '@remotion/cli';import {combineVideos} from '@remotion/renderer';import {createWriteStream,@@ -6,6 +5,7 @@ import {mkdirSync,promises,rmdirSync,+ rmSync,} from 'fs';import path, {join} from 'path';import {EFS_MOUNT_PATH, ENABLE_EFS} from './constants';@@ -132,7 +132,7 @@ export const concatVideosS3 = async ({}) => {const outdir = join(tmpDir('remotion-concat'), 'bucket');if (existsSync(outdir)) {- rmdirSync(outdir, {+ (rmSync ?? rmdirSync)(outdir, {recursive: true,});}@@ -156,10 +156,8 @@ export const concatVideosS3 = async ({});combine.end();- rmdirSync(outdir, {+ (rmSync ?? rmdirSync)(outdir, {recursive: true,});return outfile;};--CliInternals.xns(concatVideosS3);diff --git a/packages/lambda/src/create-lambda.ts b/packages/lambda/src/create-lambda.tsindex ea40ffe2be..94c2a78433 100644--- a/packages/lambda/src/create-lambda.ts+++ b/packages/lambda/src/create-lambda.ts@@ -32,7 +32,7 @@ export const createLambda = CliInternals.xns(async () => {const s3KeyRender = `${REMOTION_RENDER_FN_ZIP}${id}.zip`;const fnNameRender =RENDER_FN_PREFIX + String(Math.random()).replace('0.', '');- const [renderOut] = await Promise.all([bundleLambda('render')]);+ const renderOut = await bundleLambda('render');console.log('done Bundling');const {url, bucketName} = await deploySite(diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.tsindex d358e579a1..220196b077 100644--- a/packages/lambda/src/functions/renderer.ts+++ b/packages/lambda/src/functions/renderer.ts@@ -22,7 +22,7 @@ const renderHandler = async (params: LambdaPayload) => {const browserInstance = await getBrowserInstance();const outputDir = '/tmp/remotion-render-' + Math.random();if (fs.existsSync(outputDir)) {- fs.rmdirSync(outputDir);+ (fs.rm ?? fs.rmdirSync)(outputDir);}lambdaWriteFile({diff --git a/packages/renderer/src/combine-videos.ts b/packages/renderer/src/combine-videos.tsindex 0e10ae264e..6e448215c5 100644--- a/packages/renderer/src/combine-videos.ts+++ b/packages/renderer/src/combine-videos.ts@@ -1,7 +1,7 @@// Combine multiple video chunks, useful for decentralized renderingimport execa from 'execa';-import {rmdirSync, writeFileSync} from 'fs';+import {rmdirSync, rmSync, writeFileSync} from 'fs';import {join} from 'path';import {parseFfmpegProgress} from './parse-ffmpeg-progress';@@ -48,9 +48,9 @@ export const combineVideos = async ({await task;onProgress(numberOfFrames);- rmdirSync(filelistDir, {recursive: true});+ (rmSync ?? rmdirSync)(filelistDir, {recursive: true});} catch (err) {- rmdirSync(filelistDir, {recursive: true});+ (rmSync ?? rmdirSync)(filelistDir, {recursive: true});throw err;}};