Skip to content

Commit

Permalink
Merge pull request #50 from csscomb/4.0.0
Browse files Browse the repository at this point in the history
v4.0.0
  • Loading branch information
noahcooper authored Dec 10, 2018
2 parents 9ed994a + de1a22e commit b1ea455
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- "0.10"
- "8.0.0"
before_script:
- npm install grunt-cli
6 changes: 5 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function (grunt) {

// Before generating any new files, remove any previously-created files.
clean: {
tests: ['test/fixtures/tmp_*.css','test/fixtures/dest/*.resorted.css'],
tests: ['test/fixtures/tmp_*.css', 'test/fixtures/dest/*.resorted.css', 'test/fixtures/src/*.resorted.css'],
},

// Configuration to be run (and then tested).
Expand Down Expand Up @@ -54,6 +54,10 @@ module.exports = function (grunt) {
src: ['*.css', '!*.resorted.css'],
dest: 'test/fixtures/dest/',
ext: '.resorted.css'
},
src_only: {
src: ['test/fixtures/src/*.css', '!test/fixtures/src/*.resorted.css'],
ext: '.resorted.css'
}
},

Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,24 @@ grunt.initConfig({
});
```

#### Src Only

If you provide only a `src` with no value for `dest`, then `dest` will automatically be set to the `src` directory.

```js
grunt.initConfig({
csscomb: {
src_only: {
src: ['foo/bar.css'],
ext: '.resorted.css'
}
}
});
```

## Release History

+ v4.0.0: Update csscomb.js to v4; update dependencies; allow src only.
+ v3.1.1: Update grunt version.
+ v3.0.0: Update csscomb.js to v3.0 but `grunt-csscomb` API doesn't change.
+ v2.0.1: Stop searching config if we reach root directory.
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-csscomb",
"description": "The grunt plugin for sorting CSS properties in specific order.",
"version": "3.1.1",
"version": "4.0.0",
"homepage": "https://github.com/csscomb/grunt-csscomb",
"author": [
{
Expand Down Expand Up @@ -37,22 +37,22 @@
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.10.0"
"node": ">= 6.0.0"
},
"scripts": {
"test": "grunt test"
},
"dependencies": {
"csscomb": "~3.1.0"
"csscomb": "~4.2.0"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-nodeunit": "^0.4.1"
"grunt": "^1.0.3",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-jshint": "^2.0.0",
"grunt-contrib-nodeunit": "^2.0.0"
},
"peerDependencies": {
"grunt": ">=0.4.0"
"grunt": ">=1.0.0"
},
"keywords": [
"gruntplugin",
Expand Down
12 changes: 8 additions & 4 deletions tasks/csscomb.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,21 @@ module.exports = function (grunt) {
return true;
}
}).forEach(function (src) {
var dest = f.dest,
syntax = src.split('.').pop();
if (!dest) {
dest = grunt.file.expandMapping(src, '', { ext: f.ext || '.' + syntax })[0].dest;
}

// Get CSS from a source file:
var css = grunt.file.read(src);
var combed;

// Comb it:
grunt.log.ok('Sorting file "' + src + '"...');
var syntax = src.split('.').pop();
try {
combed = comb.processString(css, { syntax: syntax });
grunt.file.write(f.dest, combed);
comb.processString(css, { syntax: syntax }).then(function(combed) {
grunt.file.write(dest, combed);
});
} catch(e) {
grunt.log.error(e);
}
Expand Down
25 changes: 19 additions & 6 deletions test/csscomb_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports.csscomb = {

var actual = grunt.file.read('test/fixtures/tmp_resort.css');
var expected = grunt.file.read('test/expected/resort.css');
test.equal(actual, expected, 'sholud be sorted.');
test.equal(actual, expected, 'should be sorted.');

test.done();
},
Expand All @@ -17,7 +17,7 @@ exports.csscomb = {

var actual = grunt.file.read('test/fixtures/tmp_customsort.css');
var expected = grunt.file.read('test/expected/customsort.css');
test.equal(actual, expected, 'sholud be custom sorted.');
test.equal(actual, expected, 'should be custom sorted.');

test.done();
},
Expand All @@ -26,11 +26,11 @@ exports.csscomb = {

var actual = grunt.file.read('test/fixtures/tmp_multi1.css');
var expected = grunt.file.read('test/expected/multi1.css');
test.equal(actual, expected, 'sholud be sorted.');
test.equal(actual, expected, 'should be sorted.');

var actual2 = grunt.file.read('test/fixtures/tmp_multi2.css');
var expected2 = grunt.file.read('test/expected/multi2.css');
test.equal(actual2, expected2, 'sholud be sorted.');
test.equal(actual2, expected2, 'should be sorted.');

test.done();
},
Expand All @@ -39,11 +39,24 @@ exports.csscomb = {

var actual = grunt.file.read('test/fixtures/dest/multi1.resorted.css');
var expected = grunt.file.read('test/expected/multi1.css');
test.equal(actual, expected, 'sholud be sorted.');
test.equal(actual, expected, 'should be sorted.');

var actual2 = grunt.file.read('test/fixtures/dest/multi2.resorted.css');
var expected2 = grunt.file.read('test/expected/multi2.css');
test.equal(actual2, expected2, 'sholud be sorted.');
test.equal(actual2, expected2, 'should be sorted.');

test.done();
},
src_only: function (test) {
test.expect(2);

var actual = grunt.file.read('test/fixtures/src/multi1.resorted.css');
var expected = grunt.file.read('test/expected/multi1.css');
test.equal(actual, expected, 'should be sorted.');

var actual2 = grunt.file.read('test/fixtures/src/multi2.resorted.css');
var expected2 = grunt.file.read('test/expected/multi2.css');
test.equal(actual2, expected2, 'should be sorted.');

test.done();
}
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/src/multi1.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.multi1 {
z-index: 100;
display: block;
visibility: hidden;
max-height: 44px;
width: 100px;
height: 100px;
border-color: 1px #000 solid;
background-color: red;
vertical-align: 5px;
text-align: center;
font-weight: bold;
}
19 changes: 19 additions & 0 deletions test/fixtures/src/multi1.resorted.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.multi1
{
font-weight: bold;

z-index: 100;

display: block;
visibility: hidden;

width: 100px;
height: 100px;
max-height: 44px;

text-align: center;
vertical-align: 5px;

border-color: 1px #000 solid;
background-color: red;
}
13 changes: 13 additions & 0 deletions test/fixtures/src/multi2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.multi2 {
position: absolute;
top: 10px;
left: 10px;
z-index: 10;
display: table;
float: left;
margin: 10px;
padding: 10px;
width: 10px;
height: 10px;
border: 1px #fff solid;
}
17 changes: 17 additions & 0 deletions test/fixtures/src/multi2.resorted.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.multi2
{
position: absolute;
z-index: 10;
top: 10px;
left: 10px;

display: table;
float: left;

width: 10px;
height: 10px;
margin: 10px;
padding: 10px;

border: 1px #fff solid;
}

0 comments on commit b1ea455

Please sign in to comment.