|
1 | | -module.exports = function (last_updated) { |
| 1 | +module.exports = function () { |
2 | 2 |
|
3 | | - var cv = require('compare-versions'); |
| 3 | + const cv = require('compare-versions'); |
| 4 | + const lastUpdated = require('../lastUpdated.json').lastUpdated; |
4 | 5 |
|
5 | | - var date_one_month_ago = new Date().setMonth(new Date().getMonth() - 1); |
| 6 | + let dateOneMonthAgo = new Date(); |
| 7 | + dateOneMonthAgo.setMonth(new Date().getMonth() - 1); |
6 | 8 |
|
7 | | - if (new Date(last_updated) < date_one_month_ago) { |
8 | | - |
9 | | - const package_json = require('../package.json'); |
| 9 | + if (new Date(lastUpdated) < dateOneMonthAgo) { |
10 | 10 |
|
11 | 11 | fetch('https://registry.npmjs.org/browserslist-config-baseline') |
12 | 12 | .then((response) => response.json()) |
13 | 13 | .then(data => { |
14 | | - var local_version = package_json.version; |
15 | | - var remote_version = data['dist-tags'].latest; |
16 | | - if (cv.compare(local_version, remote_version, '<')) { |
| 14 | + const packageJson = require('../package.json') |
| 15 | + var localVersion = packageJson.version; |
| 16 | + var remoteVersion = data['dist-tags'].latest; |
| 17 | + if (cv.compare(localVersion, remoteVersion, '<')) { |
17 | 18 | console.warn( |
18 | | - 'Browserslist: browserslist-config-baseline \n' + |
19 | | - 'has not been updated in over a month and \n' + |
20 | | - 'you are using an out of date definition of \n' + |
21 | | - 'Baseline Widely Available. \n\n' + |
| 19 | + `You are using browserlist-config-baseline version: \t${localVersion} \n` + |
| 20 | + `The latest available version is: \t\t\t${remoteVersion} \n` + |
| 21 | + 'You may be using stale data. Please update browserslist-config-baseline \n' + |
| 22 | + 'to ensure your config is accurate. \n\n' + |
22 | 23 | ' # If using npm, please run: \n' + |
23 | 24 | ' npm i browserslist-config-baseline@latest \n\n' + |
24 | 25 | ' # If using yarn, please run: \n' + |
25 | 26 | ' yarn upgrade --latest browserslist-config-baseline \n\n' + |
26 | 27 | ' # If using bun, please run: \n' + |
27 | | - ' bun update browserslist-config-baseline@latest \n\n' |
| 28 | + ' bun update browserslist-config-baseline@latest \n\n' + |
| 29 | + 'Consider adding whichever command is appropriate to your ' + |
| 30 | + 'build scripts to avoid seeing this message in future.' |
28 | 31 | ) |
29 | 32 | } |
30 | 33 | }) |
|
0 commit comments