diff --git a/packages/cli/src/update.js b/packages/cli/src/update.js index fd13e5198..53b884fb2 100644 --- a/packages/cli/src/update.js +++ b/packages/cli/src/update.js @@ -69,6 +69,11 @@ export async function checkForUpdate() { let pkg = getPackageJSON(import.meta.url); let log = logger('cli:update'); + if (process.env.PERCY_SKIP_UPDATE_CHECK) { + log.debug('Skipping update check'); + return; + } + try { // request new release information if needed if (!releases) { diff --git a/packages/cli/test/update.test.js b/packages/cli/test/update.test.js index a00a93ff2..214d3893d 100644 --- a/packages/cli/test/update.test.js +++ b/packages/cli/test/update.test.js @@ -37,6 +37,20 @@ describe('CLI update check', () => { expect(ghAPI).not.toHaveBeenCalled(); }); + it('does not fetch the latest release information if PERCY_SKIP_UPDATE_CHECK is present', async () => { + expect(fs.existsSync('.releases')).toBe(false); + process.env.PERCY_SKIP_UPDATE_CHECK = 1; + + logger.loglevel('debug'); + + await checkForUpdate(); + expect(logger.stdout).toEqual([]); + expect(logger.stderr).toEqual(['[percy:cli:update] Skipping update check']); + expect(ghAPI).not.toHaveBeenCalled(); + + delete process.env.PERCY_SKIP_UPDATE_CHECK; + }); + it('fetchs the latest release information if the cache is outdated', async () => { ghAPI.and.returnValue([200, [{ tag_name: 'v1.0.0' }]]);