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

Function detectInstaller

packages/cli/src/utils/installerDetection.ts:79–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77 * package manager's well-known global prefix signature.
78 */
79export function detectInstaller(): InstallerInfo {
80 const realEntry = resolveEntry();
81 if (!realEntry) {
82 return {
83 kind: "skip",
84 installCommand: () => null,
85 reason: "Could not resolve process entry path",
86 };
87 }
88
89 const normalizedEntry = normalizePath(realEntry);
90
91 if (isWorkspaceLink(realEntry)) {
92 return {
93 kind: "skip",
94 installCommand: () => null,
95 reason: "Running from a workspace link (monorepo dev)",
96 };
97 }
98
99 if (isEphemeralExec(realEntry)) {
100 return {
101 kind: "skip",
102 installCommand: () => null,
103 reason: "Running via ephemeral exec (npx / bunx)",
104 };
105 }
106
107 if (isHomebrewInstall(realEntry)) {
108 return {
109 kind: "brew",
110 // Updating a brew formula isn't a straight `install`; the formula needs
111 // to have been published. Defer to `brew upgrade` which is a no-op if
112 // the tap hasn't caught up.
113 installCommand: () => "brew upgrade hyperframes",
114 reason: `Homebrew install detected at ${realEntry}`,
115 };
116 }
117
118 // bun's global install prefix is `~/.bun/install/global/node_modules/` and
119 // the bin shim lives at `~/.bun/bin/`. Both paths contain `.bun`.
120 if (normalizedEntry.includes("/.bun/")) {
121 return {
122 kind: "bun",
123 installCommand: (version) => `bun add -g hyperframes@${version}`,
124 reason: `bun global install detected at ${realEntry}`,
125 };
126 }
127
128 // pnpm's global prefix is typically `~/Library/pnpm/global/5/node_modules/`
129 // on macOS or `~/.local/share/pnpm/global/…` on Linux. `pnpm` wins when the
130 // path contains `/pnpm/global/` regardless of platform.
131 if (normalizedEntry.includes("/pnpm/global/")) {
132 return {
133 kind: "pnpm",
134 installCommand: (version) => `pnpm add -g hyperframes@${version}`,
135 reason: `pnpm global install detected at ${realEntry}`,
136 };

Callers 1

Calls 5

resolveEntryFunction · 0.85
isWorkspaceLinkFunction · 0.85
isEphemeralExecFunction · 0.85
isHomebrewInstallFunction · 0.85
normalizePathFunction · 0.70

Tested by

no test coverage detected