import path from 'path' ; import findUp from 'find-up' ; export type PackageManager = 'pnpm' | 'yarn' | 'npm' ; const LOCKS = { 'pnpm-lock.yaml' : 'pnpm' , 'yarn.lock' : 'yarn' , 'package-lock.json' : 'npm' , } ; export async function detectPackageManager ( cwd = process . cwd ( ) ) { const result = await findUp ( Object . keys ( LOCKS ) , { cwd } ) ; const agent = ( result ? LOCKS [ path . basename ( result ) ] : null ) ; return agent ; }