Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix(cli): relaunch installed host from its physical path

kashorin3c50b91e026f
diff --git a/bin/hypit.mjs b/bin/hypit.mjs
index abce53c6..8e165407 100755
--- a/bin/hypit.mjs
+++ b/bin/hypit.mjs
@@ -3,6 +3,7 @@
import { readFileSync, realpathSync } from "node:fs";
import { dirname, resolve, sep } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
+import { spawnSync } from "node:child_process";
if (process.argv.length === 3 && ["--version", "-v"].includes(process.argv[2])) {
const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
@@ -22,9 +23,18 @@ process.emitWarning = function hypitWarning(warning, ...args) {
// path so its loader and every later package import share one file identity.
const distributionRoot = realpathSync.native(resolve(dirname(fileURLToPath(import.meta.url)), ".."));
const args = process.argv.slice(2);
+const canonicalLauncher = resolve(distributionRoot, "bin", "hypit.mjs");
+if (fileURLToPath(import.meta.url) !== canonicalLauncher) {
+ const child = spawnSync(process.execPath, [...process.execArgv, canonicalLauncher, ...args], {
+ stdio: "inherit",
+ windowsHide: true,
+ });
+ if (child.error !== undefined) throw child.error;
+ process.exit(child.status ?? 1);
+}
const distributionUrl = pathToFileURL(distributionRoot + sep);
const { runHypit } = await import(new URL("bin/run.mjs", distributionUrl).href);
await runHypit(args, {
distributionRoot,
- launcher: resolve(distributionRoot, "bin", "hypit.mjs"),
+ launcher: canonicalLauncher,
});
diff --git a/bin/run.mjs b/bin/run.mjs
index 0f58ca89..07425651 100644
--- a/bin/run.mjs
+++ b/bin/run.mjs
@@ -1,12 +1,16 @@
import { register } from "tsx/esm/api";
+import { sep } from "node:path";
+import { pathToFileURL } from "node:url";
/** Enter the TypeScript application after the plain-JavaScript launcher has canonicalized itself. */
export async function runHypit(args, { distributionRoot, launcher }) {
register();
+ const distributionUrl = pathToFileURL(distributionRoot + sep);
const { installDistributionPackageResolution } =
- await import("#loader/distribution-resolution");
+ await import(new URL("packages/loader/src/node/distribution-resolution.ts", distributionUrl).href);
installDistributionPackageResolution([distributionRoot]);
- const { runInstalledCliApplication, runNodeCli } = await import("#cli");
+ const { runInstalledCliApplication, runNodeCli } =
+ await import(new URL("packages/cli/src/index.ts", distributionUrl).href);
const { createVideoDistribution } = await import("@hypit/video");
const videoDistribution = createVideoDistribution({
packageRoot: distributionRoot,
diff --git a/package.json b/package.json
index 8fd614d5..4ada663d 100644
--- a/package.json
+++ b/package.json
@@ -231,10 +231,6 @@
"import": "./packages/html-program/src/index.ts"
}
},
- "imports": {
- "#cli": "./packages/cli/src/index.ts",
- "#loader/distribution-resolution": "./packages/loader/src/node/distribution-resolution.ts"
- },
"bin": {
"hypit": "./bin/hypit.mjs"
},