File tree 3 files changed +19
-4
lines changed
3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class UpdateNotifier {
20
20
constructor ( options = { } ) {
21
21
this . options = options ;
22
22
options . pkg = options . pkg || { } ;
23
+ options . distTag = options . distTag || 'latest' ;
23
24
24
25
// Reduce pkg to the essential keys. with fallback to deprecated options
25
26
// TODO: Remove deprecated options at some point far into the future
@@ -106,12 +107,13 @@ class UpdateNotifier {
106
107
}
107
108
108
109
async checkNpm ( ) {
109
- const latest = await latestVersion ( ) ( this . packageName ) ;
110
+ const { distTag} = this . options ;
111
+ const latest = await latestVersion ( ) ( this . packageName , { version : distTag } ) ;
110
112
111
113
return {
112
114
latest,
113
115
current : this . packageVersion ,
114
- type : semverDiff ( ) ( this . packageVersion , latest ) || 'latest' ,
116
+ type : semverDiff ( ) ( this . packageVersion , latest ) || distTag ,
115
117
name : this . packageName
116
118
} ;
117
119
}
Original file line number Diff line number Diff line change @@ -137,6 +137,13 @@ Default: `false`
137
137
138
138
Allows notification to be shown when running as an npm script.
139
139
140
+ #### distTag
141
+
142
+ Type: ` string ` <br >
143
+ Default: ` latest `
144
+
145
+ Which [ dist-tag] ( https://docs.npmjs.com/adding-dist-tags-to-packages ) to use to find the latest version.
146
+
140
147
### notifier.notify([ options] )
141
148
142
149
Convenience method to display a notification message. * (See screenshot)*
Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ const generateSettings = (options = {}) => {
13
13
name : 'update-notifier-tester' ,
14
14
version : '0.0.2'
15
15
} ,
16
- callback : options . callback
16
+ callback : options . callback ,
17
+ distTag : options . distTag
17
18
} ;
18
19
} ;
19
20
@@ -35,7 +36,12 @@ test.afterEach(() => {
35
36
36
37
test ( 'check for update' , async t => {
37
38
const update = await updateNotifier ( generateSettings ( ) ) . checkNpm ( ) ;
38
- t . is ( update . current , '0.0.2' ) ;
39
+ t . is ( update . latest , '0.0.2' ) ;
40
+ } ) ;
41
+
42
+ test ( 'check for update with dist-tag' , async t => {
43
+ const update = await updateNotifier ( generateSettings ( { distTag : '0.0.3-rc1' } ) ) . checkNpm ( ) ;
44
+ t . is ( update . latest , '0.0.3-rc1' ) ;
39
45
} ) ;
40
46
41
47
test . cb ( 'check for update with callback' , t => {
You can’t perform that action at this time.
0 commit comments