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 14, 2022
1 parent 377c6da commit 502a50d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/cache-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 502a50d

Please sign in to comment.