1import { execSync } from 'node:child_process'3export type PnpmInstallOpts = {4 cwd?: string5 lockfileOnly?: boolean6 noFrozenLockfile?: boolean7 preferOffline?: boolean8 timeoutMs?: number9}11export const pnpmInstallSync = (opts: PnpmInstallOpts = {}) => {12 const flags = [13 'install',14 opts.lockfileOnly && '--lockfile-only',15 opts.noFrozenLockfile && '--no-frozen-lockfile',16 opts.preferOffline && '--prefer-offline',17 '--reporter=silent',18 ].filter(Boolean).join(' ')19 return execSync(`corepack pnpm ${flags}`, {20 stdio: 'pipe',21 timeout: opts.timeoutMs ?? 300_000,22 ...(opts.cwd ? {cwd: opts.cwd} : {}),23 })24}