Skip to content

Commit 431dac4

Browse files
committedOct 27, 2023
Require Node.js 18
1 parent a1d8d9d commit 431dac4

File tree

4 files changed

+28
-40
lines changed

4 files changed

+28
-40
lines changed
 

‎package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "module",
1414
"exports": "./index.js",
1515
"engines": {
16-
"node": ">=14.16"
16+
"node": ">=18"
1717
},
1818
"scripts": {
1919
"test": "xo && NODE_OPTIONS='--loader=esmock --no-warnings' ava"
@@ -37,26 +37,26 @@
3737
"version"
3838
],
3939
"dependencies": {
40-
"boxen": "^7.0.0",
41-
"chalk": "^5.0.1",
40+
"boxen": "^7.1.1",
41+
"chalk": "^5.3.0",
4242
"configstore": "^6.0.0",
4343
"import-lazy": "^4.0.0",
44-
"is-ci": "^3.0.1",
44+
"is-in-ci": "^0.1.0",
4545
"is-installed-globally": "^0.4.0",
4646
"is-npm": "^6.0.0",
4747
"latest-version": "^7.0.0",
4848
"pupa": "^3.1.0",
49-
"semver": "^7.3.7",
49+
"semver": "^7.5.4",
5050
"semver-diff": "^4.0.0",
5151
"xdg-basedir": "^5.1.0"
5252
},
5353
"devDependencies": {
54-
"ava": "^4.3.0",
54+
"ava": "^5.3.1",
5555
"clear-module": "^4.1.2",
56+
"esmock": "^2.5.8",
5657
"fixture-stdout": "^0.2.1",
57-
"esmock": "^1.7.8",
58-
"strip-ansi": "^7.0.1",
59-
"xo": "^0.50.0"
58+
"strip-ansi": "^7.1.0",
59+
"xo": "^0.56.0"
6060
},
6161
"ava": {
6262
"timeout": "20s",

‎readme.md

+6-18
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ Check update information.
127127

128128
Returns an `object` with:
129129

130-
- `latest` _(String)_ - Latest version.
131-
- `current` _(String)_ - Current version.
132-
- `type` _(String)_ - Type of current update. Possible values: `latest`, `major`, `minor`, `patch`, `prerelease`, `build`.
133-
- `name` _(String)_ - Package name.
130+
- `latest` *(string)* - Latest version.
131+
- `current` *(string)* - Current version.
132+
- `type` *(string)* - Type of current update. Possible values: `latest`, `major`, `minor`, `patch`, `prerelease`, `build`.
133+
- `name` *(string)* - Package name.
134134

135135
### notifier.notify(options?)
136136

@@ -191,8 +191,8 @@ Users of your module have the ability to opt-out of the update notifier by chang
191191
Users can also opt-out by [setting the environment variable](https://github.com/sindresorhus/guides/blob/main/set-environment-variables.md) `NO_UPDATE_NOTIFIER` with any value or by using the `--no-update-notifier` flag on a per run basis.
192192

193193
The check is also skipped automatically:
194-
- on CI
195-
- in unit tests (when the `NODE_ENV` environment variable is `test`)
194+
- [in CI](https://github.com/sindresorhus/is-in-ci)
195+
- in unit tests (when the `NODE_ENV` environment variable is `test`)
196196

197197
## About
198198

@@ -209,15 +209,3 @@ There are a bunch projects using it:
209209
- [Node GH](https://github.com/node-gh/gh) - GitHub command line tool
210210

211211
[And 2700+ more…](https://www.npmjs.org/browse/depended/update-notifier)
212-
213-
---
214-
215-
<div align="center">
216-
<b>
217-
<a href="https://tidelift.com/subscription/pkg/npm-update_notifier?utm_source=npm-update-notifier&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
218-
</b>
219-
<br>
220-
<sub>
221-
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
222-
</sub>
223-
</div>

‎test/update-notifier.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,30 @@ test.afterEach(() => {
3030
});
3131

3232
test('fetch info', async t => {
33-
const updateNotifier = await esmock('../index.js', undefined, {'is-ci': false});
33+
const updateNotifier = await esmock('../index.js', undefined, {'is-in-ci': false});
3434
configstorePath = updateNotifier(generateSettings()).config.path;
3535
const update = await updateNotifier(generateSettings()).fetchInfo();
3636
console.log(update);
3737
t.is(update.latest, '0.0.2');
3838
});
3939

4040
test('fetch info with dist-tag', async t => {
41-
const updateNotifier = await esmock('../index.js', undefined, {'is-ci': false});
41+
const updateNotifier = await esmock('../index.js', undefined, {'is-in-ci': false});
4242
configstorePath = updateNotifier(generateSettings()).config.path;
4343
const update = await updateNotifier(generateSettings({distTag: '0.0.3-rc1'})).fetchInfo();
4444
t.is(update.latest, '0.0.3-rc1');
4545
});
4646

4747
test('don\'t initialize configStore when NO_UPDATE_NOTIFIER is set', async t => {
48-
const updateNotifier = await esmock('../index.js', undefined, {'is-ci': false});
48+
const updateNotifier = await esmock('../index.js', undefined, {'is-in-ci': false});
4949
configstorePath = updateNotifier(generateSettings()).config.path;
5050
process.env.NO_UPDATE_NOTIFIER = '1';
5151
const notifier = updateNotifier(generateSettings());
5252
t.is(notifier.config, undefined);
5353
});
5454

5555
test('don\'t initialize configStore when --no-update-notifier is set', async t => {
56-
const updateNotifier = await esmock('../index.js', undefined, {'is-ci': false});
56+
const updateNotifier = await esmock('../index.js', undefined, {'is-in-ci': false});
5757
configstorePath = updateNotifier(generateSettings()).config.path;
5858
process.argv.push('--no-update-notifier');
5959
const notifier = updateNotifier(generateSettings());
@@ -62,7 +62,7 @@ test('don\'t initialize configStore when --no-update-notifier is set', async t =
6262

6363
test('don\'t initialize configStore when NODE_ENV === "test"', async t => {
6464
process.env.NODE_ENV = 'test';
65-
const updateNotifier = await esmock('../index.js', undefined, {'is-ci': false});
65+
const updateNotifier = await esmock('../index.js', undefined, {'is-in-ci': false});
6666
const notifier = updateNotifier(generateSettings());
6767
t.is(notifier.config, undefined);
6868
});

‎update-notifier.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {isNpmOrYarn} from 'is-npm';
1212
import isInstalledGlobally from 'is-installed-globally';
1313
import boxen from 'boxen';
1414
import {xdgConfig} from 'xdg-basedir';
15-
import isCi from 'is-ci';
15+
import isInCi from 'is-in-ci';
1616
import pupa from 'pupa';
1717

1818
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -35,14 +35,14 @@ export default class UpdateNotifier {
3535

3636
constructor(options = {}) {
3737
this.#options = options;
38-
options.pkg = options.pkg || {};
39-
options.distTag = options.distTag || 'latest';
38+
options.pkg = options.pkg ?? {};
39+
options.distTag = options.distTag ?? 'latest';
4040

4141
// Reduce pkg to the essential keys. with fallback to deprecated options
4242
// TODO: Remove deprecated options at some point far into the future
4343
options.pkg = {
44-
name: options.pkg.name || options.packageName,
45-
version: options.pkg.version || options.packageVersion,
44+
name: options.pkg.name ?? options.packageName,
45+
version: options.pkg.version ?? options.packageVersion,
4646
};
4747

4848
if (!options.pkg.name || !options.pkg.version) {
@@ -55,7 +55,7 @@ export default class UpdateNotifier {
5555
this.#isDisabled = 'NO_UPDATE_NOTIFIER' in process.env
5656
|| process.env.NODE_ENV === 'test'
5757
|| process.argv.includes('--no-update-notifier')
58-
|| isCi;
58+
|| isInCi;
5959
this._shouldNotifyInNpmScript = options.shouldNotifyInNpmScript;
6060

6161
if (!this.#isDisabled) {
@@ -119,7 +119,7 @@ export default class UpdateNotifier {
119119
return {
120120
latest,
121121
current: this.#packageVersion,
122-
type: semverDiff(this.#packageVersion, latest) || distTag,
122+
type: semverDiff(this.#packageVersion, latest) ?? distTag,
123123
name: this._packageName,
124124
};
125125
}
@@ -145,7 +145,7 @@ export default class UpdateNotifier {
145145

146146
const template = options.message || defaultTemplate;
147147

148-
options.boxenOptions = options.boxenOptions || {
148+
options.boxenOptions ??= {
149149
padding: 1,
150150
margin: 1,
151151
textAlignment: 'center',

0 commit comments

Comments
 (0)
Please sign in to comment.