From 80f6d9fce51783d56ea08ea5be0239936502f342 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Mon, 26 Aug 2024 17:43:18 +0000 Subject: [PATCH 1/3] Drop redundant dependency --- package.json | 1 - update-notifier.js | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 619b239..8c29c60 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "latest-version": "^9.0.0", "pupa": "^3.1.0", "semver": "^7.6.3", - "semver-diff": "^4.0.0", "xdg-basedir": "^5.1.0" }, "devDependencies": { diff --git a/update-notifier.js b/update-notifier.js index b239c8d..1030304 100644 --- a/update-notifier.js +++ b/update-notifier.js @@ -5,8 +5,8 @@ import path from 'node:path'; import {format} from 'node:util'; import ConfigStore from 'configstore'; import chalk from 'chalk'; -import semver from 'semver'; -import semverDiff from 'semver-diff'; +import semverDiff from 'semver/functions/diff'; +import semverGt from 'semver/functions/gt' import latestVersion from 'latest-version'; import {isNpmOrYarn} from 'is-npm'; import isInstalledGlobally from 'is-installed-globally'; @@ -126,7 +126,7 @@ export default class UpdateNotifier { notify(options) { const suppressForNpm = !this._shouldNotifyInNpmScript && isNpmOrYarn; - if (!process.stdout.isTTY || suppressForNpm || !this.update || !semver.gt(this.update.latest, this.update.current)) { + if (!process.stdout.isTTY || suppressForNpm || !this.update || !semverGt(this.update.latest, this.update.current)) { return this; } From 36bcbba9169e85901377ef550f50cd1f4ee03b96 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Mon, 26 Aug 2024 17:46:37 +0000 Subject: [PATCH 2/3] Lint me up --- update-notifier.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update-notifier.js b/update-notifier.js index 1030304..f694a53 100644 --- a/update-notifier.js +++ b/update-notifier.js @@ -6,7 +6,7 @@ import {format} from 'node:util'; import ConfigStore from 'configstore'; import chalk from 'chalk'; import semverDiff from 'semver/functions/diff'; -import semverGt from 'semver/functions/gt' +import semverGt from 'semver/functions/gt'; import latestVersion from 'latest-version'; import {isNpmOrYarn} from 'is-npm'; import isInstalledGlobally from 'is-installed-globally'; From 15167e59aa9a4c0f9c6566e8f73850024ced908d Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Mon, 26 Aug 2024 17:51:59 +0000 Subject: [PATCH 3/3] ESM imports --- update-notifier.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/update-notifier.js b/update-notifier.js index f694a53..5ab5af0 100644 --- a/update-notifier.js +++ b/update-notifier.js @@ -5,8 +5,9 @@ import path from 'node:path'; import {format} from 'node:util'; import ConfigStore from 'configstore'; import chalk from 'chalk'; -import semverDiff from 'semver/functions/diff'; -import semverGt from 'semver/functions/gt'; +// Only import what we need for performance +import semverDiff from 'semver/functions/diff.js'; +import semverGt from 'semver/functions/gt.js'; import latestVersion from 'latest-version'; import {isNpmOrYarn} from 'is-npm'; import isInstalledGlobally from 'is-installed-globally';