Changeset 0c6b92a for imaps-frontend/node_modules/browserslist/node.js
- Timestamp:
- 12/12/24 17:06:06 (5 weeks ago)
- Branches:
- main
- Parents:
- d565449
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/browserslist/node.js
rd565449 r0c6b92a 1 1 var feature = require('caniuse-lite/dist/unpacker/feature').default 2 2 var region = require('caniuse-lite/dist/unpacker/region').default 3 var fs = require('fs') 3 4 var path = require('path') 4 var fs = require('fs')5 5 6 6 var BrowserslistError = require('./error') … … 9 9 var CONFIG_PATTERN = /^browserslist-config-/ 10 10 var SCOPED_CONFIG__PATTERN = /@[^/]+(?:\/[^/]+)?\/browserslist-config(?:-|$|\/)/ 11 var TIME_TO_UPDATE_CANIUSE = 6 * 30 * 24 * 60 * 60 * 100012 11 var FORMAT = 13 12 'Browserslist config should be a string or an array ' + … … 127 126 } 128 127 128 function parsePackageOrReadConfig(file) { 129 if (path.basename(file) === 'package.json') { 130 return parsePackage(file) 131 } else { 132 return module.exports.readConfig(file) 133 } 134 } 135 129 136 function latestReleaseTime(agents) { 130 137 var latest = 0 … … 138 145 } 139 146 return latest * 1000 147 } 148 149 function getMonthsPassed(date) { 150 var now = new Date() 151 var past = new Date(date) 152 153 var years = now.getFullYear() - past.getFullYear() 154 var months = now.getMonth() - past.getMonth() 155 156 return years * 12 + months 140 157 } 141 158 … … 238 255 } else if (opts.config || process.env.BROWSERSLIST_CONFIG) { 239 256 var file = opts.config || process.env.BROWSERSLIST_CONFIG 240 if (path.basename(file) === 'package.json') { 241 return pickEnv(parsePackage(file), opts) 242 } else { 243 return pickEnv(module.exports.readConfig(file), opts) 244 } 257 return pickEnv(parsePackageOrReadConfig(file), opts) 245 258 } else if (opts.path) { 246 259 return pickEnv(module.exports.findConfig(opts.path), opts) … … 331 344 }, 332 345 333 findConfig: function findConfig(from) { 334 from = path.resolve(from) 335 336 var passed = [] 346 findConfigFile: function findConfigFile(from) { 337 347 var resolved = eachParent(from, function (dir) { 338 if (dir in configCache) {339 return configCache[dir]340 }341 342 passed.push(dir)343 344 348 var config = path.join(dir, 'browserslist') 345 349 var pkg = path.join(dir, 'package.json') … … 371 375 ) 372 376 } else if (isFile(config)) { 373 return module.exports.readConfig(config)377 return config 374 378 } else if (isFile(rc)) { 375 return module.exports.readConfig(rc)376 } else {377 return pkg Browserslist379 return rc 380 } else if (pkgBrowserslist) { 381 return pkg 378 382 } 379 383 }) 384 385 return resolved 386 }, 387 388 findConfig: function findConfig(from) { 389 from = path.resolve(from) 390 391 var fromDir = isFile(from) ? path.dirname(from) : from 392 if (fromDir in configCache) { 393 return configCache[fromDir] 394 } 395 396 var resolved 397 var configFile = this.findConfigFile(from) 398 if (configFile) { 399 resolved = parsePackageOrReadConfig(configFile) 400 } 401 380 402 if (!process.env.BROWSERSLIST_DISABLE_CACHE) { 381 passed.forEach(function (dir) { 403 var configDir = configFile && path.dirname(configFile) 404 eachParent(from, function (dir) { 382 405 configCache[dir] = resolved 406 if (dir === configDir) { 407 return null 408 } 383 409 }) 384 410 } … … 400 426 401 427 var latest = latestReleaseTime(agentsObj) 402 var halfYearAgo = Date.now() - TIME_TO_UPDATE_CANIUSE 403 404 if (latest !== 0 && latest < halfYearAgo) { 428 var monthsPassed = getMonthsPassed(latest) 429 430 if (latest !== 0 && monthsPassed >= 6) { 431 var months = monthsPassed + ' ' + (monthsPassed > 1 ? 'months' : 'month') 405 432 console.warn( 406 'Browserslist: caniuse-lite is outdated. Please run:\n' + 433 'Browserslist: browsers data (caniuse-lite) is ' + 434 months + 435 ' old. Please run:\n' + 407 436 ' npx update-browserslist-db@latest\n' + 408 437 ' Why you should do it regularly: ' +
Note:
See TracChangeset
for help on using the changeset viewer.