File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,10 @@ class UpdateNotifier {
94
94
this . update = this . config . get ( 'update' ) ;
95
95
96
96
if ( this . update ) {
97
+ // Use the real latest version instead of the cached one
98
+ this . update . current = this . packageVersion ;
99
+
100
+ // Clear cached information
97
101
this . config . delete ( 'update' ) ;
98
102
}
99
103
@@ -123,7 +127,7 @@ class UpdateNotifier {
123
127
124
128
notify ( options ) {
125
129
const suppressForNpm = ! this . shouldNotifyInNpmScript && isNpm ( ) . isNpmOrYarn ;
126
- if ( ! process . stdout . isTTY || suppressForNpm || ! this . update ) {
130
+ if ( ! process . stdout . isTTY || suppressForNpm || ! this . update || this . update . current === this . update . latest ) {
127
131
return this ;
128
132
}
129
133
Original file line number Diff line number Diff line change @@ -83,3 +83,11 @@ test('should ouput if running as npm script and shouldNotifyInNpmScript option s
83
83
notifier . notify ( { defer : false } ) ;
84
84
t . true ( stripAnsi ( errorLogs ) . includes ( 'Update available' ) ) ;
85
85
} ) ;
86
+
87
+ test ( 'should not output if current version is the latest' , t => {
88
+ setupTest ( true ) ;
89
+ const notifier = new Control ( true ) ;
90
+ notifier . update . current = '1.0.0' ;
91
+ notifier . notify ( { defer : false } ) ;
92
+ t . false ( stripAnsi ( errorLogs ) . includes ( 'Update available' ) ) ;
93
+ } ) ;
You can’t perform that action at this time.
0 commit comments