mirror of
https://gitea.com/actions/setup-node.git
synced 2024-11-24 11:09:33 +01:00
refactor: Use early return pattern
Signed-off-by: jongwooo <jongwooo.han@gmail.com>
This commit is contained in:
parent
377c6dae40
commit
b1daf0a9af
1 changed files with 11 additions and 8 deletions
|
@ -63,21 +63,24 @@ const getPackageManagerVersion = async (
|
||||||
export const getPackageManagerInfo = async (packageManager: string) => {
|
export const getPackageManagerInfo = async (packageManager: string) => {
|
||||||
if (packageManager === 'npm') {
|
if (packageManager === 'npm') {
|
||||||
return supportedPackageManagers.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}`);
|
core.debug(`Consumed yarn version is ${yarnVersion}`);
|
||||||
|
|
||||||
if (yarnVersion.startsWith('1.')) {
|
if (yarnVersion.startsWith('1.')) {
|
||||||
return supportedPackageManagers.yarn1;
|
return supportedPackageManagers.yarn1;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return supportedPackageManagers.yarn2;
|
return supportedPackageManagers.yarn2;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCacheDirectoryPath = async (
|
export const getCacheDirectoryPath = async (
|
||||||
|
|
Loading…
Reference in a new issue