@@ -8,6 +8,7 @@ var latestVersion = require('latest-version');
88var stringLength = require ( 'string-length' ) ;
99var isNpm = require ( 'is-npm' ) ;
1010var repeating = require ( 'repeating' ) ;
11+ var ONE_DAY = 1000 * 60 * 60 * 24 ;
1112
1213function 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
4243UpdateNotifier . 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 } ) ;
0 commit comments