rsnext/packages/create-next-app/helpers/should-use-yarn.ts
Maxi Gimenez cf0b1d9472
chore(create-next-app): add missing return types on helpers (#12616)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-05-10 12:55:46 +02:00

14 lines
350 B
TypeScript

import { execSync } from 'child_process'
export function shouldUseYarn(): boolean {
try {
const userAgent = process.env.npm_config_user_agent
if (userAgent) {
return Boolean(userAgent && userAgent.startsWith('yarn'))
}
execSync('yarnpkg --version', { stdio: 'ignore' })
return true
} catch (e) {
return false
}
}