Comparing version 2.5.0 to 2.6.0
@@ -32,3 +32,3 @@ 'use strict'; | ||
function stripUrls(str) { | ||
return str.replace(/url\([^\)]*\)/g, 'url()'); | ||
return str.replace(/url\([^\)]*\)/g, 'url()'); // eslint-disable-line no-useless-escape | ||
} | ||
@@ -35,0 +35,0 @@ |
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var _ = require('lodash'); | ||
@@ -8,2 +10,20 @@ var missingSupport = require('./missing-support'); | ||
function browserslist() { | ||
var dirs = path.resolve('.').split(path.sep); | ||
var config; | ||
var content; | ||
while (dirs.length) { | ||
config = dirs.concat(['browserslist']).join(path.sep); | ||
if (fs.existsSync(config) && fs.statSync(config).isFile()) { | ||
content = fs.readFileSync(config, { encoding: 'utf8' }); | ||
return content.split(/\r?\n/).join(', '); | ||
} | ||
dirs = dirs.slice(0, -1); | ||
} | ||
} | ||
function doiuse(options) { | ||
@@ -16,3 +36,7 @@ var browserQuery = options.browsers; | ||
if (!browserQuery) { | ||
browserQuery = doiuse['default'].slice(); | ||
browserQuery = browserslist(); | ||
if (!browserQuery) { | ||
browserQuery = doiuse['default'].slice(); | ||
} | ||
} | ||
@@ -19,0 +43,0 @@ |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var caniuse = require('caniuse-db/fulldata-json/data-1.0'); | ||
var caniuse = require('caniuse-db/fulldata-json/data-1.0.json'); | ||
@@ -11,0 +11,0 @@ function filterStats(browsers, stats) { |
'use strict'; | ||
var agents = require('caniuse-db/data').agents; | ||
var agents = require('caniuse-db/data.json').agents; | ||
@@ -5,0 +5,0 @@ module.exports = { |
{ | ||
"name": "doiuse", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Lint CSS for browser support against caniuse database.", | ||
@@ -45,6 +45,12 @@ "main": "lib/doiuse.js", | ||
"babel": "^5.2.13", | ||
"mock-fs": "^3.12.1", | ||
"postcss-import": "^7.1.3", | ||
"standard": "^8.1.0", | ||
"tape": "^4.0.0" | ||
}, | ||
"standard": { | ||
"ignore": [ | ||
"data/*.js" | ||
] | ||
} | ||
} |
@@ -7,2 +7,3 @@ var fs = require('fs') | ||
var hasKeys = require('./has-keys') | ||
var mock = require('mock-fs') | ||
@@ -98,9 +99,9 @@ test('leaves css alone by default', function (t) { | ||
postcss([atImport(), | ||
doiuse({ | ||
browsers: ['ie 6'], | ||
ignoreFiles: ['**/ignore-file.css'], | ||
onFeatureUsage: function (usageInfo) { | ||
count++ | ||
} | ||
})]) | ||
doiuse({ | ||
browsers: ['ie 6'], | ||
ignoreFiles: ['**/ignore-file.css'], | ||
onFeatureUsage: function (usageInfo) { | ||
count++ | ||
} | ||
})]) | ||
.process(css, {from: cssPath}) | ||
@@ -124,8 +125,8 @@ .then(function () { | ||
var processor = postcss([atImport(), | ||
doiuse({ | ||
browsers: ['ie 6'], | ||
onFeatureUsage: function (usageInfo) { | ||
count++ | ||
} | ||
})]) | ||
doiuse({ | ||
browsers: ['ie 6'], | ||
onFeatureUsage: function (usageInfo) { | ||
count++ | ||
} | ||
})]) | ||
@@ -143,1 +144,28 @@ processor.process(ignoreCss, {from: ignoreCssPath}) | ||
}) | ||
test('info with browserslist file', function (t) { | ||
mock({ | ||
'browserslist': 'Safari 8\nIE >= 11' | ||
}) | ||
var actual = doiuse({}).info().browsers | ||
var expected = [['ie', '11'], ['safari', '8']] | ||
t.deepEqual(actual, expected) | ||
mock.restore() | ||
t.end() | ||
}) | ||
test('info with no browserslist file or browsers config', function (t) { | ||
var actual = doiuse({}).info().browsers | ||
var expected = doiuse({ | ||
browsers: doiuse['default'] | ||
}).info().browsers | ||
t.deepEqual(actual, expected) | ||
t.end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69816
73
1941
5
4