diff --git a/src/cache-utils.ts b/src/cache-utils.ts index 5df3e718a..dfb9cdc94 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -61,23 +61,30 @@ const getPackageManagerVersion = async ( }; export const getPackageManagerInfo = async (packageManager: string) => { + if ( + packageManager !== 'npm' && + packageManager !== 'pnpm' && + packageManager !== 'yarn' + ) { + return null; + } + if (packageManager === 'npm') { return supportedPackageManagers.npm; - } else if (packageManager === 'pnpm') { + } + + if (packageManager === 'pnpm') { return supportedPackageManagers.pnpm; - } else if (packageManager === 'yarn') { - const yarnVersion = await getPackageManagerVersion('yarn', '--version'); + } - core.debug(`Consumed yarn version is ${yarnVersion}`); + const yarnVersion = await getPackageManagerVersion('yarn', '--version'); + core.debug(`Consumed yarn version is ${yarnVersion}`); - if (yarnVersion.startsWith('1.')) { - return supportedPackageManagers.yarn1; - } else { - return supportedPackageManagers.yarn2; - } - } else { - return null; + if (yarnVersion.startsWith('1.')) { + return supportedPackageManagers.yarn1; } + + return supportedPackageManagers.yarn2; }; export const getCacheDirectoryPath = async (