Skip to content

Set package manager versions #549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cache-save.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ export async function run() {
const cacheLock = core.getInput('cache');
await cachePackages(cacheLock);
} catch (error) {
core.setFailed(error.message);
core.setFailed((error as Error).message);
}
}

28 changes: 23 additions & 5 deletions src/cache-utils.ts
Original file line number Diff line number Diff line change
@@ -47,17 +47,35 @@ export const getCommandOutput = async (toolCommand: string) => {
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 (
packageManager: string,
command: string
) => {
const stdOut = await getCommandOutput(`${packageManager} ${command}`);
let packageManagerVersion = resolvePackageManagerVersionInput(packageManager);

if (!stdOut) {
throw new Error(`Could not retrieve version of ${packageManager}`);
}
if (packageManagerVersion) {
return packageManagerVersion;
} else {
const stdOut = await getCommandOutput(`${packageManager} ${command}`);

return stdOut;
if (!stdOut) {
throw new Error(`Could not retrieve version of ${packageManager}`);
}

return stdOut;
}
};

export const getPackageManagerInfo = async (packageManager: string) => {
6 changes: 3 additions & 3 deletions src/installer.ts
Original file line number Diff line number Diff line change
@@ -116,9 +116,9 @@ export async function getNode(
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
);
} else {
core.info(err.message);
core.info((err as Error).message);
}
core.debug(err.stack);
core.debug((err as Error).stack!);
core.info('Falling back to download directly from Node');
}

@@ -334,7 +334,7 @@ async function resolveVersionFromManifest(
return info?.resolvedVersion;
} catch (err) {
core.info('Unable to resolve version from manifest...');
core.debug(err.message);
core.debug((err as Error).message);
}
}

2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ export async function run() {
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
);
} catch (err) {
core.setFailed(err.message);
core.setFailed((err as Error).message);
}
}