Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
Release 2.10.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Feb 8, 2017
1 parent a012b48 commit 3517524
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
9 changes: 5 additions & 4 deletions index.js
Expand Up @@ -7,9 +7,9 @@ class CleanCSSMinifier {
this.options = config && config.plugins && config.plugins.cleancss || {};
}

optimize(params) {
const data = params.data;
const path = params.path;
optimize(file) {
const data = file.data;
const path = file.path;

try {
if (this.options.ignored && this.options.ignored.test(path)) {
Expand All @@ -21,7 +21,8 @@ class CleanCSSMinifier {
}

try {
return Promise.resolve(new CleanCSS(this.options).minify(data).styles || data);
const min = new CleanCSS(this.options).minify(data);
return Promise.resolve(min.styles || data);
} catch (error) {
return Promise.reject(`CSS minify failed on ${path}: ${error}`);
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "clean-css-brunch",
"version": "2.0.0",
"version": "2.10.0",
"description": "Adds CleanCSS support to brunch.",
"author": "Paul Miller (http://paulmillr.com/)",
"homepage": "https://github.com/brunch/clean-css-brunch",
Expand All @@ -13,12 +13,12 @@
"test": "eslint index.js && mocha"
},
"dependencies": {
"clean-css": "~3.4.8"
"clean-css": "~4.0"
},
"devDependencies": {
"chai": "^3.4.1",
"eslint": "^3.12.2",
"eslint-config-brunch": "brunch/eslint-config-brunch",
"eslint-config-brunch": "^1",
"mocha": "^2.3.4"
},
"eslintConfig": {
Expand Down
14 changes: 7 additions & 7 deletions test.js
Expand Up @@ -30,22 +30,22 @@ describe('Plugin', () => {
});

it('should compile and produce a result clean-css options are reflected in', done => {
plugin.options = {
keepSpecialComments: 0,
keepBreaks: true,
};
plugin.options = {level: 2, specialComments: false};

const eol = require('os').EOL;

const content = '/*! comment */\n#first { color: red; }\r\n#second { color: blue; }';
const expected = `#first{color:red}${eol}#second{color:#00f}`;
const content = '#first { color: red; }\r\n#second { color: blue; }';
const expected = `#first{color:red}#second{color:#00f}`;

plugin.optimize({data: content, path: ''})
.then(data => {
expect(data).to.equal(expected);
done();
})
.catch(error => expect(error).not.to.be.ok);
.catch(error => {
console.log(error);
expect(error).not.to.be.ok
});
});

it('should return a non minified css if path is in "ignore" list', done => {
Expand Down

0 comments on commit 3517524

Please sign in to comment.