Skip to content

🎥 Make videos programmatically with React

entry point

Jonny Burger600b4fd56a0d
diff --git a/packages/cli/src/entry-point.ts b/packages/cli/src/entry-point.ts
index 49c83f94ff..21796e5f8d 100644
--- a/packages/cli/src/entry-point.ts
+++ b/packages/cli/src/entry-point.ts
@@ -1,5 +1,5 @@
import {RenderInternals} from '@remotion/renderer';
-import {existsSync} from 'fs';
+import {existsSync, lstatSync} from 'fs';
import path from 'path';
import {ConfigInternals} from './config';
import {Log} from './log';
@@ -26,6 +26,34 @@ export const findEntryPoint = (
file: string | null;
remainingArgs: string[];
reason: string;
+} => {
+ const result = findEntryPointInner(args, remotionRoot);
+ if (result.file === null) {
+ return result;
+ }
+
+ if (!existsSync(result.file)) {
+ throw new Error(
+ `${result.file} was chosen as the entry point (reason = ${result.reason}) but it does not exist.`
+ );
+ }
+
+ if (lstatSync(result.file).isDirectory()) {
+ throw new Error(
+ `${result.file} was chosen as an entry point (reason = ${result.reason}) but it is a directory - it needs to be a file.`
+ );
+ }
+
+ return result;
+};
+
+const findEntryPointInner = (
+ args: string[],
+ remotionRoot: string
+): {
+ file: string | null;
+ remainingArgs: string[];
+ reason: string;
} => {
// 1st priority: Explicitly passed entry point
let file: string | null = args[0];
diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.ts
index f8802e55dc..e925fb1e0e 100644
--- a/packages/lambda/src/cli/commands/sites/create.ts
+++ b/packages/lambda/src/cli/commands/sites/create.ts
@@ -1,6 +1,4 @@
import {CliInternals, ConfigInternals} from '@remotion/cli';
-import {existsSync, lstatSync} from 'fs';
-import path from 'path';
import {Internals} from 'remotion';
import {deploySite} from '../../../api/deploy-site';
import {getOrCreateBucket} from '../../../api/get-or-create-bucket';
@@ -41,21 +39,6 @@ export const sitesCreateSubcommand = async (
Log.verbose('Entry point:', file, 'Reason:', reason);
- const absoluteFile = path.join(process.cwd(), file);
- if (!existsSync(absoluteFile)) {
- Log.error(
- `No file exists at ${absoluteFile}. Make sure the path exists and try again.`
- );
- quit(1);
- }
-
- if (lstatSync(absoluteFile).isDirectory()) {
- Log.error(
- `You passed a path ${absoluteFile} but it is a directory. Pass a file instead.`
- );
- quit(1);
- }
-
const desiredSiteName = parsedLambdaCli['site-name'] ?? undefined;
if (desiredSiteName !== undefined) {
validateSiteName(desiredSiteName);
@@ -113,7 +96,7 @@ export const sitesCreateSubcommand = async (
const uploadStart = Date.now();
const {serveUrl, siteName, stats} = await deploySite({
- entryPoint: absoluteFile,
+ entryPoint: file,
siteName: desiredSiteName,
bucketName,
options: {