MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / findMotionSpec

Function findMotionSpec

packages/cli/src/utils/motionSpec.ts:115–131  ·  view source on GitHub ↗
(projectDir: string)

Source from the content-addressed store, hash-verified

113 * Returns null when none is present.
114 */
115export function findMotionSpec(projectDir: string): string | null {
116 if (!existsSync(projectDir)) return null;
117 const entries = readdirSync(projectDir);
118 const sidecars = entries.filter((name) => name.endsWith(".motion.json")).sort();
119 if (!sidecars[0]) return null;
120 if (sidecars.length === 1) return join(projectDir, sidecars[0]);
121 const htmlBases = new Set(
122 entries.filter((name) => name.endsWith(".html")).map((name) => basename(name, ".html")),
123 );
124 const matched = sidecars.filter((name) => htmlBases.has(basename(name, ".motion.json")));
125 if (matched.length > 1) {
126 throw new Error(
127 `ambiguous motion sidecars in ${projectDir}: ${matched.join(", ")} each match a composition — remove the sidecars you do not need, or use one composition per project`,
128 );
129 }
130 return join(projectDir, matched[0] ?? sidecars[0]);
131}
132
133export function readMotionSpec(path: string): MotionSpecParse {
134 let raw: unknown;

Callers 2

motionSpec.test.tsFile · 0.85
runFunction · 0.85

Calls 1

basenameFunction · 0.85

Tested by

no test coverage detected