From 6cb083216361be1a65c9317efbcefab69e5db81d Mon Sep 17 00:00:00 2001 From: "Saad A. Bazaz" Date: Sat, 7 Dec 2024 01:26:34 +0500 Subject: [PATCH] Update update-notifier.js --- update-notifier.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/update-notifier.js b/update-notifier.js index 300aa8e..db8a648 100644 --- a/update-notifier.js +++ b/update-notifier.js @@ -38,6 +38,7 @@ export default class UpdateNotifier { this.#options = options; options.pkg ??= {}; options.distTag ??= 'latest'; + options.printFn ??= console.error; // Reduce pkg to the essential keys. with fallback to deprecated options // TODO: Remove deprecated options at some point far into the future @@ -76,7 +77,7 @@ export default class UpdateNotifier { + chalk.cyan(format(' sudo chown -R $USER:$(id -gn $USER) %s ', xdgConfig)); process.on('exit', () => { - console.error(boxen(message, {textAlignment: 'center'})); + options.printFn(boxen(message, {textAlignment: 'center'})); }); } } @@ -165,10 +166,10 @@ export default class UpdateNotifier { ); if (options.defer === false) { - console.error(message); + options.printFn(message); } else { process.on('exit', () => { - console.error(message); + options.printFn(message); }); }