|
1 | 1 | import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; |
2 | 2 | import { dirname, join } from "node:path"; |
3 | | -import { spawnSync } from "node:child_process"; |
4 | | -import { install } from "panam"; |
| 3 | +import pm from "panam/pm"; |
5 | 4 | import type { IntegrationData } from "../types.ts"; |
6 | | -import { getPackageManagerName } from "../utils/package-manager.ts"; |
7 | 5 |
|
8 | 6 | /** |
9 | 7 | * Merge scripts, dependencies, and devDependencies from an integration's |
@@ -88,23 +86,19 @@ export function integrationHasDeps(integration: IntegrationData): boolean { |
88 | 86 | * Install dependencies in the given working directory using panam. |
89 | 87 | */ |
90 | 88 | export async function installDeps(cwd: string): Promise<void> { |
91 | | - await install({ cwd }); |
| 89 | + await pm.install({ cwd }); |
92 | 90 | } |
93 | 91 |
|
94 | 92 | /** |
95 | 93 | * Run a postInstall command in the given working directory. |
96 | 94 | * Uses npx for npm, or the package manager name directly for pnpm/yarn/bun. |
97 | 95 | */ |
98 | 96 | export async function runPostInstall(postInstallCmd: string, cwd: string): Promise<void> { |
99 | | - const parts = postInstallCmd.split(" "); |
100 | | - const [command, ...args] = parts; |
| 97 | + const [command] = postInstallCmd.split(" "); |
101 | 98 | if (!command) return; |
102 | 99 |
|
103 | | - const pm = getPackageManagerName(); |
104 | | - const executor = pm === "npm" ? "npx" : pm; |
105 | | - |
106 | | - const result = spawnSync(executor, [command, ...args], { cwd, stdio: "inherit" }); |
107 | | - if (result.status !== 0) { |
108 | | - throw new Error(`Post-install command failed: ${postInstallCmd} (exit code ${result.status})`); |
| 100 | + const result = await pm.x(postInstallCmd, { cwd }); |
| 101 | + if (!result.status) { |
| 102 | + throw new Error(`Post-install command failed: ${postInstallCmd}`); |
109 | 103 | } |
110 | 104 | } |
0 commit comments