Skip to content

🎥 Make videos programmatically with React

fix

Jonny Burgera40af9150b61
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.ts
index c7447f3fd1..29bc8f63ff 100644
--- a/packages/bundler/src/bundle.ts
+++ b/packages/bundler/src/bundle.ts
@@ -1,5 +1,5 @@
import type {GitSource} from '@remotion/studio-shared';
-import {SOURCE_MAP_ENDPOINT} from '@remotion/studio-shared';
+import {getProjectName, SOURCE_MAP_ENDPOINT} from '@remotion/studio-shared';
import fs, {promises} from 'node:fs';
import os from 'node:os';
import path from 'node:path';
@@ -52,27 +52,6 @@ export type LegacyBundleOptions = {
onSymlinkDetected?: (path: string) => void;
};
-const getProjectName = ({
- gitSource,
- resolvedRemotionRoot,
-}: {
- gitSource: GitSource | null;
- resolvedRemotionRoot: string;
-}) => {
- // Directory name
- if (!gitSource) {
- return path.basename(resolvedRemotionRoot);
- }
-
- // Subfolder name of a Git repo, e.g `example`
- if (gitSource.relativeFromGitRoot.trim()) {
- return path.basename(gitSource.relativeFromGitRoot.trim());
- }
-
- // Name of the repo
- return gitSource.name;
-};
-
export const getConfig = ({
entryPoint,
outDir,
@@ -297,6 +276,7 @@ export async function bundle(...args: Arguments): Promise<string> {
projectName: getProjectName({
gitSource: actualArgs.gitSource ?? null,
resolvedRemotionRoot,
+ basename: path.basename,
}),
});
diff --git a/packages/studio-server/src/routes.ts b/packages/studio-server/src/routes.ts
index be5fd9505b..d0a7d68f7c 100644
--- a/packages/studio-server/src/routes.ts
+++ b/packages/studio-server/src/routes.ts
@@ -7,7 +7,7 @@ import type {
RenderJob,
SymbolicatedStackFrame,
} from '@remotion/studio-shared';
-import {SOURCE_MAP_ENDPOINT} from '@remotion/studio-shared';
+import {getProjectName, SOURCE_MAP_ENDPOINT} from '@remotion/studio-shared';
import {createReadStream, existsSync, statSync} from 'node:fs';
import type {IncomingMessage, ServerResponse} from 'node:http';
import path, {join} from 'node:path';
@@ -92,6 +92,11 @@ const handleFallback = async ({
renderDefaults: getRenderDefaults(),
publicFolderExists: existsSync(publicDir) ? publicDir : null,
gitSource,
+ projectName: getProjectName({
+ basename: path.basename,
+ gitSource,
+ resolvedRemotionRoot: remotionRoot,
+ }),
}),
);
};
diff --git a/packages/studio-shared/src/get-project-name.ts b/packages/studio-shared/src/get-project-name.ts
new file mode 100644
index 0000000000..eb9d440a9c
--- /dev/null
+++ b/packages/studio-shared/src/get-project-name.ts
@@ -0,0 +1,24 @@
+import type {GitSource} from './git-source';
+
+export const getProjectName = ({
+ gitSource,
+ resolvedRemotionRoot,
+ basename,
+}: {
+ gitSource: GitSource | null;
+ resolvedRemotionRoot: string;
+ basename: (str: string) => string;
+}) => {
+ // Directory name
+ if (!gitSource) {
+ return basename(resolvedRemotionRoot);
+ }
+
+ // Subfolder name of a Git repo, e.g `example`
+ if (gitSource.relativeFromGitRoot.trim()) {
+ return basename(gitSource.relativeFromGitRoot.trim());
+ }
+
+ // Name of the repo
+ return gitSource.name;
+};
diff --git a/packages/studio-shared/src/index.ts b/packages/studio-shared/src/index.ts
index 6260ef8077..5d7a6df468 100644
--- a/packages/studio-shared/src/index.ts
+++ b/packages/studio-shared/src/index.ts
@@ -24,6 +24,7 @@ export {
ErrorLocation,
getLocationFromBuildError,
} from './get-location-from-build-error';
+export {getProjectName} from './get-project-name';
export type {GitSource} from './git-source';
export {
HotMiddlewareMessage,