Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/browserslist/node.js

    rd565449 r0c6b92a  
    11var feature = require('caniuse-lite/dist/unpacker/feature').default
    22var region = require('caniuse-lite/dist/unpacker/region').default
     3var fs = require('fs')
    34var path = require('path')
    4 var fs = require('fs')
    55
    66var BrowserslistError = require('./error')
     
    99var CONFIG_PATTERN = /^browserslist-config-/
    1010var SCOPED_CONFIG__PATTERN = /@[^/]+(?:\/[^/]+)?\/browserslist-config(?:-|$|\/)/
    11 var TIME_TO_UPDATE_CANIUSE = 6 * 30 * 24 * 60 * 60 * 1000
    1211var FORMAT =
    1312  'Browserslist config should be a string or an array ' +
     
    127126}
    128127
     128function parsePackageOrReadConfig(file) {
     129  if (path.basename(file) === 'package.json') {
     130    return parsePackage(file)
     131  } else {
     132    return module.exports.readConfig(file)
     133  }
     134}
     135
    129136function latestReleaseTime(agents) {
    130137  var latest = 0
     
    138145  }
    139146  return latest * 1000
     147}
     148
     149function 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
    140157}
    141158
     
    238255    } else if (opts.config || process.env.BROWSERSLIST_CONFIG) {
    239256      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)
    245258    } else if (opts.path) {
    246259      return pickEnv(module.exports.findConfig(opts.path), opts)
     
    331344  },
    332345
    333   findConfig: function findConfig(from) {
    334     from = path.resolve(from)
    335 
    336     var passed = []
     346  findConfigFile: function findConfigFile(from) {
    337347    var resolved = eachParent(from, function (dir) {
    338       if (dir in configCache) {
    339         return configCache[dir]
    340       }
    341 
    342       passed.push(dir)
    343 
    344348      var config = path.join(dir, 'browserslist')
    345349      var pkg = path.join(dir, 'package.json')
     
    371375        )
    372376      } else if (isFile(config)) {
    373         return module.exports.readConfig(config)
     377        return config
    374378      } else if (isFile(rc)) {
    375         return module.exports.readConfig(rc)
    376       } else {
    377         return pkgBrowserslist
     379        return rc
     380      } else if (pkgBrowserslist) {
     381        return pkg
    378382      }
    379383    })
     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
    380402    if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
    381       passed.forEach(function (dir) {
     403      var configDir = configFile && path.dirname(configFile)
     404      eachParent(from, function (dir) {
    382405        configCache[dir] = resolved
     406        if (dir === configDir) {
     407          return null
     408        }
    383409      })
    384410    }
     
    400426
    401427    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')
    405432      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' +
    407436          '  npx update-browserslist-db@latest\n' +
    408437          '  Why you should do it regularly: ' +
Note: See TracChangeset for help on using the changeset viewer.