@@ -525,6 +525,18 @@ async function runSites(args: Record<string, unknown>): Promise<void> {
525525
526526// ── render ──────────────────────────────────────────────────────────────────
527527
528+ function resolveCloudRunFps (
529+ args : Record < string , unknown > ,
530+ projectDir : string ,
531+ command : "render" | "render-batch" ,
532+ ) : 24 | 30 | 60 {
533+ const fps =
534+ parseIntFlag ( args . fps ) ?? readAllowedCompositionFpsFromDir ( projectDir , [ 24 , 30 , 60 ] ) ?? 30 ;
535+ if ( fps === 24 || fps === 30 || fps === 60 ) return fps ;
536+ console . error ( `[cloudrun ${ command } ] --fps must be 24, 30, or 60; got ${ fps } .` ) ;
537+ failCommand ( ) ;
538+ }
539+
528540// fallow-ignore-next-line complexity
529541async function runRender ( args : Record < string , unknown > ) : Promise < void > {
530542 const projectDir = args . target as string | undefined ;
@@ -540,12 +552,7 @@ async function runRender(args: Record<string, unknown>): Promise<void> {
540552 console . error ( "[cloudrun render] --width and --height are required." ) ;
541553 failCommand ( ) ;
542554 }
543- const fps =
544- parseIntFlag ( args . fps ) ?? readAllowedCompositionFpsFromDir ( projectDir , [ 24 , 30 , 60 ] ) ?? 30 ;
545- if ( fps !== 24 && fps !== 30 && fps !== 60 ) {
546- console . error ( `[cloudrun render] --fps must be 24, 30, or 60; got ${ fps } .` ) ;
547- failCommand ( ) ;
548- }
555+ const fps = resolveCloudRunFps ( args , projectDir , "render" ) ;
549556 const state = readState ( args ) ;
550557 const variables = resolveAndValidateVariables ( args , resolve ( projectDir ) ) ;
551558 const config = buildRenderConfig ( args , fps , width , height , variables ) ;
@@ -651,12 +658,7 @@ async function runRenderBatch(args: Record<string, unknown>): Promise<void> {
651658 console . error ( "[cloudrun render-batch] --width and --height are required." ) ;
652659 failCommand ( ) ;
653660 }
654- const fps =
655- parseIntFlag ( args . fps ) ?? readAllowedCompositionFpsFromDir ( projectDir , [ 24 , 30 , 60 ] ) ?? 30 ;
656- if ( fps !== 24 && fps !== 30 && fps !== 60 ) {
657- console . error ( `[cloudrun render-batch] --fps must be 24, 30, or 60; got ${ fps } .` ) ;
658- failCommand ( ) ;
659- }
661+ const fps = resolveCloudRunFps ( args , projectDir , "render-batch" ) ;
660662 if ( ! existsSync ( resolve ( batchPath ) ) ) {
661663 console . error ( `[cloudrun render-batch] batch file not found: ${ batchPath } ` ) ;
662664 failCommand ( ) ;
0 commit comments