mirror of
https://github.com/actions/setup-node
synced 2024-12-22 21:22:42 +00:00
Merge pull request #327 from WtfJoke/addCacheHitOutPut
Add 'cache-hit' as output
This commit is contained in:
commit
270253e841
4 changed files with 7 additions and 0 deletions
|
@ -140,6 +140,7 @@ describe('cache-restore', () => {
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
`${packageManager} cache is not found`
|
`${packageManager} cache is not found`
|
||||||
);
|
);
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -167,6 +168,7 @@ describe('cache-restore', () => {
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
`${packageManager} cache is not found`
|
`${packageManager} cache is not found`
|
||||||
);
|
);
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,6 +29,9 @@ inputs:
|
||||||
version:
|
version:
|
||||||
description: 'Deprecated. Use node-version instead. Will not be supported after October 1, 2019'
|
description: 'Deprecated. Use node-version instead. Will not be supported after October 1, 2019'
|
||||||
deprecationMessage: 'The version property will not be supported after October 1, 2019. Use node-version instead'
|
deprecationMessage: 'The version property will not be supported after October 1, 2019. Use node-version instead'
|
||||||
|
outputs:
|
||||||
|
cache-hit:
|
||||||
|
description: 'A boolean value to indicate if a cache was hit'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/setup/index.js'
|
main: 'dist/setup/index.js'
|
||||||
|
|
1
dist/setup/index.js
vendored
1
dist/setup/index.js
vendored
|
@ -44674,6 +44674,7 @@ exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0
|
||||||
core.debug(`primary key is ${primaryKey}`);
|
core.debug(`primary key is ${primaryKey}`);
|
||||||
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
|
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
|
||||||
const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
|
const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
|
||||||
|
core.setOutput('cache-hit', Boolean(cacheKey));
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
core.info(`${packageManager} cache is not found`);
|
core.info(`${packageManager} cache is not found`);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -42,6 +42,7 @@ export const restoreCache = async (
|
||||||
core.saveState(State.CachePrimaryKey, primaryKey);
|
core.saveState(State.CachePrimaryKey, primaryKey);
|
||||||
|
|
||||||
const cacheKey = await cache.restoreCache([cachePath], primaryKey);
|
const cacheKey = await cache.restoreCache([cachePath], primaryKey);
|
||||||
|
core.setOutput('cache-hit', Boolean(cacheKey));
|
||||||
|
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
core.info(`${packageManager} cache is not found`);
|
core.info(`${packageManager} cache is not found`);
|
||||||
|
|
Loading…
Reference in a new issue