rsnext/packages/create-next-app/helpers/should-use-yarn.ts
Sriram Thiagarajan eec18ecafe
[create-next-app] update logic for shouldUseYarn function (#11683)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-06 09:32:20 +02:00

14 lines
341 B
TypeScript

import { execSync } from 'child_process'
export function shouldUseYarn() {
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
}
}