Skip to content

Commit f070a1e

Browse files
committed
1 parent be57796 commit f070a1e

5 files changed

Lines changed: 12 additions & 21 deletions

File tree

.jshintrc

Lines changed: 0 additions & 13 deletions
This file was deleted.

check.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22
var updateNotifier = require('./');
33
var options = JSON.parse(process.argv[2]);
4-
var updateNotifier = new updateNotifier.UpdateNotifier(options);
4+
5+
updateNotifier = new updateNotifier.UpdateNotifier(options);
56

67
updateNotifier.checkNpm(function (err, update) {
78
if (err) {

index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var latestVersion = require('latest-version');
88
var stringLength = require('string-length');
99
var isNpm = require('is-npm');
1010
var repeating = require('repeating');
11+
var ONE_DAY = 1000 * 60 * 60 * 24;
1112

1213
function UpdateNotifier(options) {
1314
this.options = options = options || {};
@@ -17,15 +18,15 @@ function UpdateNotifier(options) {
1718
options.pkg = {
1819
name: options.pkg.name || options.packageName,
1920
version: options.pkg.version || options.packageName
20-
}
21+
};
2122

2223
if (!options.pkg.name || !options.pkg.version) {
2324
throw new Error('pkg.name and pkg.version required');
2425
}
2526

2627
this.packageName = options.pkg.name;
2728
this.packageVersion = options.pkg.version;
28-
this.updateCheckInterval = typeof options.updateCheckInterval === 'number' ? options.updateCheckInterval : 1000 * 60 * 60 * 24; // 1 day
29+
this.updateCheckInterval = typeof options.updateCheckInterval === 'number' ? options.updateCheckInterval : ONE_DAY;
2930
this.hasCallback = typeof options.callback === 'function';
3031
this.callback = options.callback || function () {};
3132

@@ -41,7 +42,8 @@ function UpdateNotifier(options) {
4142

4243
UpdateNotifier.prototype.check = function () {
4344
if (this.hasCallback) {
44-
return this.checkNpm(this.callback);
45+
this.checkNpm(this.callback);
46+
return;
4547
}
4648

4749
if (this.config.get('optOut') || 'NO_UPDATE_NOTIFIER' in process.env || process.argv.indexOf('--no-update-notifier') !== -1) {
@@ -87,7 +89,6 @@ UpdateNotifier.prototype.notify = function (opts) {
8789
}
8890

8991
opts = opts || {};
90-
opts.defer = opts.defer === undefined ? true : false;
9192

9293
var line1 = ' Update available: ' + chalk.green.bold(this.update.latest) +
9394
chalk.dim(' (current: ' + this.update.current + ')') + ' ';
@@ -107,7 +108,7 @@ UpdateNotifier.prototype.notify = function (opts) {
107108
side + line2 + repeating(' ', line2rest) + side + '\n' +
108109
bottom + '\n';
109110

110-
if (opts.defer) {
111+
if (opts.defer === undefined) {
111112
process.on('exit', function () {
112113
console.error(message);
113114
});

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"node": ">=0.10.0"
1414
},
1515
"scripts": {
16-
"test": "mocha --timeout 20000"
16+
"test": "xo && mocha --timeout 20000"
1717
},
1818
"files": [
1919
"index.js",
@@ -42,6 +42,7 @@
4242
"string-length": "^1.0.0"
4343
},
4444
"devDependencies": {
45-
"mocha": "*"
45+
"mocha": "*",
46+
"xo": "*"
4647
}
4748
}

test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-env mocha */
12
'use strict';
23
var assert = require('assert');
34
var fs = require('fs');

0 commit comments

Comments
 (0)