mirror of
https://gitea.com/actions/setup-node.git
synced 2024-11-24 11:09:33 +01:00
Add support for specifying versions for package managers (#529)
This commit is contained in:
parent
7884734703
commit
5a3778b347
1 changed files with 23 additions and 5 deletions
|
@ -47,10 +47,27 @@ export const getCommandOutput = async (toolCommand: string) => {
|
||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resolvePackageManagerVersionInput = (
|
||||||
|
packageManager: string
|
||||||
|
): string | undefined => {
|
||||||
|
let version = core.getInput(`${packageManager}-version`);
|
||||||
|
|
||||||
|
if (version !== '') {
|
||||||
|
core.info(`Using ${packageManager} with version ${version}.`);
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const getPackageManagerVersion = async (
|
const getPackageManagerVersion = async (
|
||||||
packageManager: string,
|
packageManager: string,
|
||||||
command: string
|
command: string
|
||||||
) => {
|
) => {
|
||||||
|
let packageManagerVersion = resolvePackageManagerVersionInput(packageManager);
|
||||||
|
|
||||||
|
if (packageManagerVersion) {
|
||||||
|
return packageManagerVersion;
|
||||||
|
} else {
|
||||||
const stdOut = await getCommandOutput(`${packageManager} ${command}`);
|
const stdOut = await getCommandOutput(`${packageManager} ${command}`);
|
||||||
|
|
||||||
if (!stdOut) {
|
if (!stdOut) {
|
||||||
|
@ -58,6 +75,7 @@ const getPackageManagerVersion = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
return stdOut;
|
return stdOut;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPackageManagerInfo = async (packageManager: string) => {
|
export const getPackageManagerInfo = async (packageManager: string) => {
|
||||||
|
|
Loading…
Reference in a new issue