Skip to content

Commit

Permalink
✨ Skip github update check if PERCY_SKIP_UPDATE_CHECK is truthy (#1127
Browse files Browse the repository at this point in the history
)

* ✨ skip github update check if `PERCY_SKIP_UPDATE_CHECK` is truthy

* allow any truthy value

* test for PERCY_SKIP_UPDATE_CHECK

Co-authored-by: Samarjeet <[email protected]>
  • Loading branch information
itsjwala and samarsault authored Nov 10, 2022
1 parent d2e812d commit 65c8442
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/cli/src/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions packages/cli/test/update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }]]);

Expand Down

0 comments on commit 65c8442

Please sign in to comment.