Skip to content

Commit 944f447

Browse files
Fixes clean-css#51 - excluding files via glob negated pattern.
1 parent a0cec11 commit 944f447

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

History.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
[5.1.0 / 2021-xx-xx](https://github.com/jakubpawlowicz/clean-css-cli/compare/5.0...HEAD)
2+
==================
3+
4+
* Fixed issue [#51](https://github.com/jakubpawlowicz/clean-css-cli/issues/51) - excluding files via glob negated pattern.
5+
16
[5.0.1 / 2021-02-11](https://github.com/jakubpawlowicz/clean-css-cli/compare/v5.0.0...v5.0.1)
27
==================
38

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Previously a part of clean-css it's a separate package since clean-css 4.0.
1919
- [Node.js version support](#nodejs-version-support)
2020
- [Install](#install)
2121
- [Use](#use)
22+
* [What's new in version 5.1](#whats-new-in-version-51)
2223
* [What's new in version 5.0](#whats-new-in-version-50)
2324
* [What's new in version 4.3](#whats-new-in-version-43)
2425
* [What's new in version 4.2](#whats-new-in-version-42)
@@ -60,6 +61,12 @@ Note: Global install via -g option is recommended unless you want to execute the
6061
cleancss -o one.min.css one.css
6162
```
6263

64+
## What's new in version 5.1
65+
66+
clean-css-cli 5.1 will introduce the following changes / features:
67+
68+
* accept `!path/to/file` as a way of telling `cleancss` to ignore such file, also accepts any available glob patterns.
69+
6370
## What's new in version 5.0
6471

6572
clean-css-cli 5.0 introduces the following changes / features:
@@ -383,6 +390,12 @@ cleancss --batch --batch-suffix '.min' styles/*.css
383390
384391
Remember you can use [glob matching](https://www.npmjs.com/package/glob#glob-primer) to match exactly the files you want.
385392
393+
Since clean-css-cli 5.1 you can also use a negated pattern to exclude some files from being matched, e.g.
394+
395+
```shell
396+
cleancss --batch styles/*.css !styles/*.min.css
397+
```
398+
386399
## How to specify a custom rounding precision?
387400
388401
The level 1 `roundingPrecision` optimization option accept a string with per-unit rounding precision settings, e.g.

index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,13 @@ function findArgumentTo(option, rawArgs, args) {
173173
}
174174

175175
function expandGlobs(paths) {
176-
return paths.reduce(function (accumulator, path) {
177-
return accumulator.concat(glob.sync(path, { nodir: true, nonull: true}));
176+
var globPatterns = paths.filter(function (path) { return path[0] != '!'; });
177+
var ignoredGlobPatterns = paths
178+
.filter(function (path) { return path[0] == '!'; })
179+
.map(function (path) { return path.substring(1); });
180+
181+
return globPatterns.reduce(function (accumulator, path) {
182+
return accumulator.concat(glob.sync(path, { ignore: ignoredGlobPatterns, nodir: true, nonull: true }));
178183
}, []);
179184
}
180185

test/binary-test.js

+18
Original file line numberDiff line numberDiff line change
@@ -861,4 +861,22 @@ vows.describe('cleancss')
861861
}
862862
})
863863
})
864+
.addBatch({
865+
'batch processing with wildcard and exclude paths': binaryContext('-b ./test/fixtures-batch-5/partials/\\*\\*/*.css !./test/fixtures-batch-5/partials/one* !./test/fixtures-batch-5/partials/fiv?.css', {
866+
'setup': function () {
867+
execSync('cp -fr test/fixtures test/fixtures-batch-5');
868+
},
869+
'creates two separate minified files': function () {
870+
assert.isTrue(fs.existsSync('test/fixtures-batch-5/partials/extra/four-min.css'));
871+
assert.isTrue(fs.existsSync('test/fixtures-batch-5/partials/extra/three-min.css'));
872+
assert.isFalse(fs.existsSync('test/fixtures-batch-5/partials/one-min.css'));
873+
assert.isTrue(fs.existsSync('test/fixtures-batch-5/partials/two-min.css'));
874+
assert.isTrue(fs.existsSync('test/fixtures-batch-5/partials/quoted-svg-min.css'));
875+
assert.isFalse(fs.existsSync('test/fixtures-batch-5/partials/five-min.css'));
876+
},
877+
'teardown': function () {
878+
execSync('rm -fr test/fixtures-batch-5');
879+
}
880+
})
881+
})
864882
.export(module);

0 commit comments

Comments
 (0)