Skip to content

Commit 3181ec9

Browse files
seamusleahysimonsmith
authored andcommitted
Reduce complexity of checkGlob
1 parent 98b49f3 commit 3181ec9

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

index.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var validateSelectors = require('./lib/validate-selectors');
55
var generateConfig = require('./lib/generate-config');
66
var toRegexp = require('./lib/to-regexp');
77
var path = require('path');
8-
var minimatch = require('minimatch');
8+
var minimatchList = require('minimatch-list');
99

1010
var DEFINE_VALUE = '([-_a-zA-Z0-9]+)\\s*(?:;\\s*(weak))?';
1111
var DEFINE_DIRECTIVE = new RegExp(
@@ -89,17 +89,9 @@ module.exports = postcss.plugin('postcss-bem-linter', function(primaryOptions, s
8989
}
9090

9191
function checkGlob(file, globs) {
92-
if (file.indexOf(process.cwd()) === 0) {
93-
file = file.substr(process.cwd().length);
94-
95-
if (file.charAt(0) === path.sep) {
96-
file = file.substr(1);
97-
}
98-
}
99-
100-
return globs.reduce(function (accumulator, pattern) {
101-
return accumulator || minimatch(file, pattern);
102-
}, false);
92+
// PostCSS turns relative paths into absolute paths
93+
file = path.relative(process.cwd(), file);
94+
return minimatchList(file, globs);
10395
}
10496

10597
function isImplicitComponent(file) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"lib"
88
],
99
"dependencies": {
10-
"minimatch": "^3.0.3",
10+
"minimatch-list": "0.0.1",
1111
"postcss": "^5.0.0",
1212
"postcss-resolve-nested-selector": "^0.1.1"
1313
},

0 commit comments

Comments
 (0)