1
0
Fork 0
mirror of https://github.com/actions/setup-node synced 2024-12-22 13:12:43 +00:00

refactor: Use early return pattern

Signed-off-by: jongwooo <jongwooo.han@gmail.com>
This commit is contained in:
Jongwoo Han 2022-12-15 03:16:14 +09:00 committed by jongwooo
parent 377c6dae40
commit b1daf0a9af

View file

@ -63,21 +63,24 @@ const getPackageManagerVersion = async (
export const getPackageManagerInfo = async (packageManager: string) => {
if (packageManager === 'npm') {
return supportedPackageManagers.npm;
} else if (packageManager === 'pnpm') {
return supportedPackageManagers.pnpm;
} else if (packageManager === 'yarn') {
const yarnVersion = await getPackageManagerVersion('yarn', '--version');
}
if (packageManager === 'pnpm') {
return supportedPackageManagers.pnpm;
}
if (packageManager === 'yarn') {
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;
return supportedPackageManagers.yarn2;
}
return null;
};
export const getCacheDirectoryPath = async (