Skip to content

Commit

Permalink
Merge branch 'master' into tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Feb 18, 2024
2 parents 532e231 + e0bb7a1 commit 090fd66
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class Client extends EventEmitter {
args
);
};
}

if (this.options.checkForUpdates) {
updater.checkForUpdates();
}
if (this.options.checkForUpdates) {
updater.checkForUpdates();
}
/**
* All cache entries
Expand Down Expand Up @@ -357,7 +357,7 @@ class Client extends EventEmitter {
* @prop {number} [cacheSize=-1] The amount how many results will be cached. (`-1` for infinity)
* @prop {boolean} [silent=false] Don't automatically put warnings into console.
* @prop {object} [headers={}] Extra Headers ( like User-Agent ) to add to request.
* @prop {boolean} [checkForUpdates=false] Enable/Disable check for new version of hypixel-api-reborn.
* @prop {boolean} [checkForUpdates=true] Enable/Disable check for new version of hypixel-api-reborn.
*/
const defaultCache = require('./Private/defaultCache.js');
/**
Expand Down
18 changes: 2 additions & 16 deletions src/Private/updater.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
/* eslint-disable require-jsdoc */
/* eslint-disable no-console */
const fetch = require('node-fetch');
const Errors = require('../Errors');
class Updater {
Expand All @@ -11,23 +11,9 @@ class Updater {
const latestVersion = metadata['dist-tags'].latest;
const compare = this.compare(currentVersion, latestVersion);
if (compare === -1) {
this.notify(latestVersion);
console.log(`New version of hypixel-api-reborn is available! Current version: ${currentVersion}, Latest version: ${latestVersion}`);
}
}
notify(newVersion) {
console.log(`
New version of hypixel-api-reborn is available!
v${newVersion}
Changelog: https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/releases/tag/${newVersion}
\x1b[33mnpm i hypixel-api-reborn@${newVersion}\x1b[0m
or
\x1b[33myarn add hypixel-api-reborn@${newVersion}\x1b[0m
`);
}
compare(a, b) {
const pa = a.split('.');
const pb = b.split('.');
Expand Down
2 changes: 1 addition & 1 deletion src/Private/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Validation {
syncWithHeaders: !!options.syncWithHeaders,
headers: options.headers || {},
silent: !!options.silent,
checkForUpdates: options.checkForUpdates || false
checkForUpdates: options.checkForUpdates || true
};
}

Expand Down

0 comments on commit 090fd66

Please sign in to comment.