Lines 1-49javascript
3// The @inflexa-ai/inflexa `bin`: resolves and executes the platform-native
4// binary delivered by one of the @inflexa-ai/inflexa-<platform>-<arch>
5// optionalDependencies, falling back to the copy postinstall.js downloaded
6// when optional dependencies were skipped. The `bin` stays a Node script —
7// pointing it at the raw executable breaks the shims npm/pnpm/bun generate
9const { spawnSync } = require("node:child_process");
10const fs = require("node:fs");
HighChild Process
Package source references child process execution.
bin/inflexa.jsView on unpkg · L8 MediumDynamic Require
Package source references dynamic require/import behavior.
bin/inflexa.jsView on unpkg · L8 11const path = require("node:path");
13function resolveBinary() {
14 if (process.env.INFLEXA_BIN_PATH) return process.env.INFLEXA_BIN_PATH;
15 const binName = process.platform === "win32" ? "inflexa.exe" : "inflexa";
16 // TODO(extend): pick a -musl platform package on musl libc once those
17 // binaries ship (inflexa-ai/inflexa#107).
18 const pkg = `@inflexa-ai/inflexa-${process.platform}-${process.arch}`;
20 const pkgJson = require.resolve(`${pkg}/package.json`);
21 return path.join(path.dirname(pkgJson), "bin", binName);
23 const fallback = path.join(__dirname, "..", "bin-fallback", binName);
24 if (fs.existsSync(fallback)) return fallback;
29const bin = resolveBinary();
33 `inflexa: no binary available for ${process.platform}-${process.arch}.`,
34 "The platform package (an optionalDependency) was not installed, and the",
35 "postinstall fallback did not deliver a binary either. Reinstall without",
36 "--no-optional/--omit=optional/--ignore-scripts, or install the platform",
37 `package directly: npm install @inflexa-ai/inflexa-${process.platform}-${process.arch}`,
43const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
44if (result.error) {
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
bin/inflexa.jsView on unpkg · L36 45 console.error(`inflexa: failed to start ${bin}: ${result.error.message}`);
48process.exit(typeof result.status === "number" ? result.status : 0);