1
0
Fork 0
mirror of https://github.com/actions/setup-node synced 2024-11-09 15:12:40 +00:00

replace throw with warn

This commit is contained in:
Sergey Dolin 2022-12-09 12:05:59 +01:00 committed by Sergey Dolin
parent 676975d9aa
commit b28830cbe2
5 changed files with 17 additions and 9 deletions

View file

@ -46,7 +46,8 @@ describe('cache-utils', () => {
isFeatureAvailable.mockImplementation(() => false); isFeatureAvailable.mockImplementation(() => false);
process.env['GITHUB_SERVER_URL'] = 'https://www.test.com'; process.env['GITHUB_SERVER_URL'] = 'https://www.test.com';
expect(() => isCacheFeatureAvailable()).toThrowError( expect(isCacheFeatureAvailable()).toBeFalsy();
expect(warningSpy).toHaveBeenCalledWith(
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.' 'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
); );
}); });

View file

@ -728,8 +728,9 @@ describe('setup-node', () => {
await main.run(); await main.run();
expect(cnSpy).toHaveBeenCalledWith( expect(warningSpy).toHaveBeenCalledWith(
`::error::Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.${osm.EOL}` // `::error::Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.${osm.EOL}`
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
); );
}); });

View file

@ -61187,8 +61187,10 @@ exports.isGhes = isGhes;
function isCacheFeatureAvailable() { function isCacheFeatureAvailable() {
if (cache.isFeatureAvailable()) if (cache.isFeatureAvailable())
return true; return true;
if (isGhes()) if (isGhes()) {
throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
return false;
}
core.warning('The runner was not able to contact the cache service. Caching will be skipped'); core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false; return false;
} }

6
dist/setup/index.js vendored
View file

@ -73141,8 +73141,10 @@ exports.isGhes = isGhes;
function isCacheFeatureAvailable() { function isCacheFeatureAvailable() {
if (cache.isFeatureAvailable()) if (cache.isFeatureAvailable())
return true; return true;
if (isGhes()) if (isGhes()) {
throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
return false;
}
core.warning('The runner was not able to contact the cache service. Caching will be skipped'); core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false; return false;
} }

View file

@ -107,10 +107,12 @@ export function isGhes(): boolean {
export function isCacheFeatureAvailable(): boolean { export function isCacheFeatureAvailable(): boolean {
if (cache.isFeatureAvailable()) return true; if (cache.isFeatureAvailable()) return true;
if (isGhes()) if (isGhes()) {
throw new Error( core.warning(
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.' 'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
); );
return false;
}
core.warning( core.warning(
'The runner was not able to contact the cache service. Caching will be skipped' 'The runner was not able to contact the cache service. Caching will be skipped'