Skills › HyperFrames › media-use › resolve.mjs
resolve.mjs
31 lines · skills/media-use/scripts/resolve.mjs at a595755
1#!/usr/bin/env node
2import { spawnSync } from "node:child_process";
3import { existsSync } from "node:fs";
4import { join } from "node:path";
5import { fileURLToPath } from "node:url";
6import { resolveNpxInvocation } from "./lib/npx-sync.mjs";
8// Installed plugins have no monorepo packages/ tree. The plugin launcher passes
9// the release version and suppression environment through to this legacy shim.
10const pluginVersion = process.env.HYPERFRAMES_PLUGIN_VERSION;
11if (pluginVersion) {
12 const invocation = resolveNpxInvocation(
13 ["--yes", `hyperframes@${pluginVersion}`, "media-use", "resolve", ...process.argv.slice(2)],
14 { stdio: "inherit" },
15 );
16 const result = spawnSync(invocation.cmd, invocation.args, invocation.opts);
17 if (result.error) console.error(result.error.message);
18 process.exit(result.status ?? 1);
19}
20const root = join(fileURLToPath(new URL("../../../", import.meta.url)));
21const dist = join(root, "packages/cli/dist/cli.js");
22const result = existsSync(dist)
23 ? spawnSync(process.execPath, [dist, "media-use", "resolve", ...process.argv.slice(2)], {
24 stdio: "inherit",
25 })
26 : spawnSync(
27 "bun",
28 [join(root, "packages/cli/src/cli.ts"), "media-use", "resolve", ...process.argv.slice(2)],
29 { stdio: "inherit" },
30 );
31process.exit(result.status ?? 1);