Skip to content

🎥 Make videos programmatically with React

support symbolic link

Jonny Burger7c328ae00711
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.ts
index cfd29b8986..7214985870 100644
--- a/packages/bundler/src/bundle.ts
+++ b/packages/bundler/src/bundle.ts
@@ -180,8 +180,24 @@ export async function bundle(...args: Arguments): Promise<string> {
? path.resolve(resolvedRemotionRoot, options.publicDir)
: path.join(resolvedRemotionRoot, 'public');
const to = path.join(outDir, 'public');
+
+ let symlinkWarningShown = false;
+ const showSymlinkWarning = (ent: fs.Dirent, src: string) => {
+ if (symlinkWarningShown) {
+ return;
+ }
+
+ symlinkWarningShown = true;
+ console.warn(
+ `\nFound a symbolic link in the public folder (${path.join(
+ src,
+ ent.name
+ )}). The symlink will be forwarded into the bundle.`
+ );
+ };
+
if (fs.existsSync(from)) {
- await copyDir({src: from, dest: to});
+ await copyDir({src: from, dest: to, onSymlinkDetected: showSymlinkWarning});
}
const html = indexHtml({
diff --git a/packages/bundler/src/copy-dir.ts b/packages/bundler/src/copy-dir.ts
index 375aea472e..2ce8c4aebc 100644
--- a/packages/bundler/src/copy-dir.ts
+++ b/packages/bundler/src/copy-dir.ts
@@ -1,7 +1,15 @@
import fs from 'fs';
import path from 'path';
-export async function copyDir({src, dest}: {src: string; dest: string}) {
+export async function copyDir({
+ src,
+ dest,
+ onSymlinkDetected,
+}: {
+ src: string;
+ dest: string;
+ onSymlinkDetected: (entry: fs.Dirent, dir: string) => void;
+}) {
await fs.promises.mkdir(dest, {recursive: true});
const entries = await fs.promises.readdir(src, {withFileTypes: true});
@@ -10,9 +18,10 @@ export async function copyDir({src, dest}: {src: string; dest: string}) {
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
- await copyDir({src: srcPath, dest: destPath});
+ await copyDir({src: srcPath, dest: destPath, onSymlinkDetected});
} else if (entry.isSymbolicLink()) {
const realpath = await fs.promises.realpath(srcPath);
+ onSymlinkDetected(entry, src);
await fs.promises.symlink(realpath, destPath);
} else {
await fs.promises.copyFile(srcPath, destPath);