Skip to content

🎥 Make videos programmatically with React

fix passing a serve URL to `npx remotion render` breaking

Jonny Burgerf0eaa324ae9a
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index 267a786c36..b3b252ac72 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -52,10 +52,6 @@ export const render = async (remotionRoot: string, args: string[]) => {
process.exit(1);
}
- const fullPath = RenderInternals.isServeUrl(file)
- ? file
- : path.join(process.cwd(), file);
-
const downloadMap = RenderInternals.makeDownloadMap();
if (parsedCli.frame) {
@@ -114,14 +110,14 @@ export const render = async (remotionRoot: string, args: string[]) => {
});
const steps: RenderStep[] = [
- RenderInternals.isServeUrl(fullPath) ? null : ('bundling' as const),
+ RenderInternals.isServeUrl(file) ? null : ('bundling' as const),
'rendering' as const,
shouldOutputImageSequence ? null : ('stitching' as const),
].filter(Internals.truthy);
const {urlOrBundle, cleanup: cleanupBundle} = await bundleOnCliOrTakeServeUrl(
{
- fullPath,
+ fullPath: file,
remotionRoot,
steps,
publicDir,
@@ -191,7 +187,10 @@ export const render = async (remotionRoot: string, args: string[]) => {
Log.info(
chalk.gray(
- `Entry point = ${file} (${entryPointReason}), Composition = ${compositionId} (${reason}), Codec = ${codec} (${codecReason}), Output = ${relativeOutputLocation}`
+ `Entry point = ${path.relative(
+ process.cwd(),
+ file
+ )} (${entryPointReason}), Composition = ${compositionId} (${reason}), Codec = ${codec} (${codecReason}), Output = ${relativeOutputLocation}`
)
);
diff --git a/packages/cli/src/test/find-entry-point.test.ts b/packages/cli/src/test/find-entry-point.test.ts
new file mode 100644
index 0000000000..f568eee7ff
--- /dev/null
+++ b/packages/cli/src/test/find-entry-point.test.ts
@@ -0,0 +1,38 @@
+import path from 'path';
+import {expect, test} from 'vitest';
+import {findEntryPoint} from '../entry-point';
+
+test('Should accept URL as entry point', () => {
+ const entryPoint = findEntryPoint(
+ ['https://www.example.com'],
+ path.resolve(process.cwd(), '..', 'example')
+ );
+
+ expect(entryPoint.file).toBe('https://www.example.com');
+ expect(entryPoint.remainingArgs).toEqual([]);
+ expect(entryPoint.reason).toEqual('argument passed');
+});
+
+test('Should find entry point automatically', () => {
+ const entryPoint = findEntryPoint(
+ [],
+ path.resolve(process.cwd(), '..', 'example')
+ );
+
+ expect(entryPoint.file).toBe('src/index.ts');
+ expect(entryPoint.remainingArgs).toEqual([]);
+ expect(entryPoint.reason).toEqual('common paths');
+});
+
+test('Should use explicit entry point', () => {
+ const entryPoint = findEntryPoint(
+ ['src/ts-entry.tsx'],
+ path.resolve(process.cwd(), '..', 'example')
+ );
+
+ expect(entryPoint.file).toBe(
+ '/Users/jonathanburger/remotion/packages/example/src/ts-entry.tsx'
+ );
+ expect(entryPoint.remainingArgs).toEqual([]);
+ expect(entryPoint.reason).toEqual('argument passed - found in root');
+});