You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+12-20Lines changed: 12 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,14 +15,12 @@ Inform users of your package of updates in a non-intrusive way.
15
15
-[About](#about)
16
16
-[Users](#users)
17
17
18
-
19
18
## Install
20
19
21
20
```
22
21
$ npm install update-notifier
23
22
```
24
23
25
-
26
24
## Usage
27
25
28
26
### Simple
@@ -71,15 +69,13 @@ if (notifier.update) {
71
69
}
72
70
```
73
71
74
-
75
72
## How
76
73
77
74
Whenever you initiate the update notifier and it's not within the interval threshold, it will asynchronously check with npm in the background for available updates, then persist the result. The next time the notifier is initiated, the result will be loaded into the `.update` property. This prevents any impact on your package startup performance.
78
75
The update check is done in a unref'ed [child process](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). This means that if you call `process.exit`, the check will still be performed in its own process.
79
76
80
77
The first time the user runs your app, it will check for an update, and even if an update is available, it will wait the specified `updateCheckInterval` before notifying the user. This is done to not be annoying to the user, but might surprise you as an implementer if you're testing whether it works. Check out [`example.js`](example.js) to quickly test out `update-notifier` and see how you can test that it works in your app.
81
78
82
-
83
79
## API
84
80
85
81
### notifier = updateNotifier(options)
@@ -96,17 +92,17 @@ Type: `object`
96
92
97
93
##### name
98
94
99
-
*Required*<br>
95
+
*Required*\
100
96
Type: `string`
101
97
102
98
##### version
103
99
104
-
*Required*<br>
100
+
*Required*\
105
101
Type: `string`
106
102
107
103
#### updateCheckInterval
108
104
109
-
Type: `number`<br>
105
+
Type: `number`\
110
106
Default: `1000 * 60 * 60 * 24`*(1 day)*
111
107
112
108
How often to check for updates.
@@ -119,19 +115,19 @@ Passing a callback here will make it check for an update directly and report rig
119
115
120
116
#### shouldNotifyInNpmScript
121
117
122
-
Type: `boolean`<br>
118
+
Type: `boolean`\
123
119
Default: `false`
124
120
125
121
Allows notification to be shown when running as an npm script.
126
122
127
123
#### distTag
128
124
129
-
Type: `string`<br>
130
-
Default: `latest`
125
+
Type: `string`\
126
+
Default: `'latest'`
131
127
132
128
Which [dist-tag](https://docs.npmjs.com/adding-dist-tags-to-packages) to use to find the latest version.
133
129
134
-
### notifier.notify([options])
130
+
### notifier.notify(options?)
135
131
136
132
Convenience method to display a notification message. *(See screenshot)*
137
133
@@ -143,33 +139,32 @@ Type: `object`
143
139
144
140
##### defer
145
141
146
-
Type: `boolean`<br>
142
+
Type: `boolean`\
147
143
Default: `true`
148
144
149
145
Defer showing the notification to after the process has exited.
Message that will be shown when an update is available.
157
153
158
154
##### isGlobal
159
155
160
-
Type: `boolean`<br>
161
-
Default: auto-detect
156
+
Type: `boolean`\
157
+
Default: Auto-detect
162
158
163
159
Include the `-g` argument in the default message's `npm i` recommendation. You may want to change this if your CLI package can be installed as a dependency of another project, and don't want to recommend a global installation. This option is ignored if you supply your own `message` (see above).
Options object that will be passed to [`boxen`](https://github.com/sindresorhus/boxen).
171
167
172
-
173
168
### User settings
174
169
175
170
Users of your module have the ability to opt-out of the update notifier by changing the `optOut` property to `true` in `~/.config/configstore/update-notifier-[your-module-name].json`. The path is available in `notifier.config.path`.
@@ -180,12 +175,10 @@ The check is also skipped automatically:
180
175
- on CI
181
176
- in unit tests (when the `NODE_ENV` environment variable is `test`)
182
177
183
-
184
178
## About
185
179
186
180
The idea for this module came from the desire to apply the browser update strategy to CLI tools, where everyone is always on the latest version. We first tried automatic updating, which we discovered wasn't popular. This is the second iteration of that idea, but limited to just update notifications.
187
181
188
-
189
182
## Users
190
183
191
184
There are a bunch projects using it:
@@ -199,7 +192,6 @@ There are a bunch projects using it:
0 commit comments