refactor: add tmp extract check to avoid issue in unit tests

As `hasYarn` function is called when `npm_init.ts` is parsed and loaded there are some issue with mock in unit tests.
This commit is contained in:
Gaëtan Maisse 2020-06-07 18:39:54 +02:00
parent 100ffac29c
commit aa02e872dc
No known key found for this signature in database
GPG Key ID: D934C0EF3714A8A8

View File

@ -9,7 +9,7 @@ export function hasYarn() {
const lockFile = findUp.sync(['yarn.lock', 'package-lock.json']);
const hasYarnLock = lockFile && path.basename(lockFile) === 'yarn.lock';
if (yarnAvailable.status === 0 && (hasYarnLock || npmAvailable.status !== 0)) {
if (yarnAvailable && yarnAvailable.status === 0 && (hasYarnLock || npmAvailable.status !== 0)) {
return true;
}
return false;