Skip to content

Commit

Permalink
Disable on CI (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored and sindresorhus committed Oct 30, 2017
1 parent 3e5cea0 commit 38d5679
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Expand Up @@ -12,6 +12,7 @@ const isNpm = importLazy('is-npm');
const isInstalledGlobally = importLazy('is-installed-globally');
const boxen = importLazy('boxen');
const xdgBasedir = importLazy('xdg-basedir');
const isCi = importLazy('is-ci');
const ONE_DAY = 1000 * 60 * 60 * 24;

class UpdateNotifier {
Expand All @@ -37,7 +38,8 @@ class UpdateNotifier {
this.hasCallback = typeof options.callback === 'function';
this.callback = options.callback || (() => {});
this.disabled = 'NO_UPDATE_NOTIFIER' in process.env ||
process.argv.indexOf('--no-update-notifier') !== -1;
process.argv.indexOf('--no-update-notifier') !== -1 ||
isCi();

if (!this.disabled && !this.hasCallback) {
try {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -37,6 +37,7 @@
"chalk": "^2.0.1",
"configstore": "^3.0.0",
"import-lazy": "^2.1.0",
"is-ci": "^1.0.10",
"is-installed-globally": "^0.1.0",
"is-npm": "^1.0.0",
"latest-version": "^3.0.0",
Expand All @@ -47,6 +48,7 @@
"ava": "*",
"clear-module": "^2.1.0",
"fixture-stdout": "^0.2.1",
"mock-require": "^2.0.2",
"strip-ansi": "^4.0.0",
"xo": "^0.18.2"
}
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Expand Up @@ -159,6 +159,8 @@ Users of your module have the ability to opt-out of the update notifier by chang

Users can also opt-out by [setting the environment variable](https://github.com/sindresorhus/guides/blob/master/set-environment-variables.md) `NO_UPDATE_NOTIFIER` with any value or by using the `--no-update-notifier` flag on a per run basis.

The check is also skipped on CI automatically.


## About

Expand Down
5 changes: 5 additions & 0 deletions test/update-notifier.js
@@ -1,5 +1,10 @@
import fs from 'fs';
import test from 'ava';
import mockRequire from 'mock-require';

mockRequire('is-ci', false);

// eslint-disable-next-line import/first
import updateNotifier from '..';

const generateSettings = options => {
Expand Down

0 comments on commit 38d5679

Please sign in to comment.