Skip to content

Commit

Permalink
refactor: Use early return pattern
Browse files Browse the repository at this point in the history
Signed-off-by: jongwooo <jongwooo.han@gmail.com>
  • Loading branch information
jongwooo committed Dec 29, 2022
1 parent 377c6da commit b1daf0a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/cache-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,24 @@ const getPackageManagerVersion = async (
export const getPackageManagerInfo = async (packageManager: string) => {
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');
}

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 (
Expand Down

0 comments on commit b1daf0a

Please sign in to comment.