GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Normalize custom statistics versions in coverage · browserslist/browserslist@cac8029

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • index.js
  • test
    • coverage.test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎index.js‎

Copy file name to clipboardExpand all lines: index.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ browserslist.coverage = function (browsers, stats) {
558558
} else if (stats === 'my stats') {
559559
var opts = {}
560560
opts.path = path.resolve ? path.resolve('.') : '.'
561-
var customStats = env.getStat(opts)
561+
var customStats = env.getStat(opts, browserslist.data)
562562
if (!customStats) {
563563
throw new BrowserslistError('Custom usage statistics was not provided')
564564
}
@@ -578,6 +578,7 @@ browserslist.coverage = function (browsers, stats) {
578578
if ('dataByBrowser' in stats) {
579579
stats = stats.dataByBrowser
580580
}
581+
stats = env.getStat({ stats: stats }, browserslist.data)
581582
data = {}
582583
for (var name in stats) {
583584
for (var version in stats[name]) {
Collapse file

‎test/coverage.test.js‎

Copy file name to clipboardExpand all lines: test/coverage.test.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ let browserslist = require('..')
77

88
let STATS = join(__dirname, 'fixtures', 'browserslist-stats.json')
99
let CUSTOM_STATS = join(__dirname, 'fixtures', 'stats.json')
10+
let ANDROID = join(__dirname, 'fixtures', 'android-stats.json')
1011

1112
let custom = {
1213
ie: {
@@ -96,4 +97,11 @@ test('supports custom statistics', () => {
9697
is(browserslist.coverage(['ie 9'], { dataByBrowser: custom }), 10)
9798
})
9899

100+
test('normalizes versions in custom statistics', () => {
101+
let browsers = browserslist('> 3% in my stats', { stats: ANDROID })
102+
equal(browserslist.coverage(browsers, { and_chr: { 10: 4 } }), 4)
103+
process.env.BROWSERSLIST_STATS = ANDROID
104+
equal(browserslist.coverage(browsers, 'my stats'), 4)
105+
})
106+
99107
test.run()

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.