mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 05:40:54 +00:00
fix: add found cached toolpath to PATH before executing node
This commit is contained in:
parent
df568f01a8
commit
c4d0bc7f39
@ -225,7 +225,7 @@ describe('setup-node', () => {
|
|||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
`Found v14.0.0 in cache @ ${toolPath} but it does not satisfy the requested version (12.16.2)`
|
`Found v14.0.0 in cache @ ${expPath} but it does not satisfy the requested version (12.16.2)`
|
||||||
);
|
);
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
`Attempting to download ${versionSpec}...`
|
`Attempting to download ${versionSpec}...`
|
||||||
|
@ -82,19 +82,26 @@ export async function getNode(
|
|||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.info(`Found in cache @ ${toolPath}`);
|
core.info(`Found in cache @ ${toolPath}`);
|
||||||
|
|
||||||
|
if (osPlat != 'win32') {
|
||||||
|
toolPath = path.join(toolPath, 'bin');
|
||||||
|
}
|
||||||
|
|
||||||
|
core.addPath(toolPath);
|
||||||
|
|
||||||
const {stdout: installedVersion} = await exec.getExecOutput(
|
const {stdout: installedVersion} = await exec.getExecOutput(
|
||||||
'node',
|
'node',
|
||||||
['--version'],
|
['--version'],
|
||||||
{ignoreReturnCode: true}
|
{ignoreReturnCode: true}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!semver.satisfies(installedVersion, versionSpec)) {
|
if (semver.satisfies(installedVersion, versionSpec)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
core.info(
|
core.info(
|
||||||
`Found ${installedVersion} in cache @ ${toolPath} but it does not satisfy the requested version (${versionSpec})`
|
`Found ${installedVersion} in cache @ ${toolPath} but it does not satisfy the requested version (${versionSpec})`
|
||||||
);
|
);
|
||||||
toolPath = '';
|
toolPath = '';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!toolPath) {
|
if (!toolPath) {
|
||||||
core.info(`Attempting to download ${versionSpec}...`);
|
core.info(`Attempting to download ${versionSpec}...`);
|
||||||
|
Loading…
Reference in New Issue
Block a user