Skip to content

Commit b1ea455

Browse files
authored
Merge pull request #50 from csscomb/4.0.0
v4.0.0
2 parents 9ed994a + de1a22e commit b1ea455

File tree

10 files changed

+119
-20
lines changed

10 files changed

+119
-20
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: node_js
22
node_js:
3-
- "0.10"
3+
- "8.0.0"
44
before_script:
55
- npm install grunt-cli

Gruntfile.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = function (grunt) {
2424

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

3030
// Configuration to be run (and then tested).
@@ -54,6 +54,10 @@ module.exports = function (grunt) {
5454
src: ['*.css', '!*.resorted.css'],
5555
dest: 'test/fixtures/dest/',
5656
ext: '.resorted.css'
57+
},
58+
src_only: {
59+
src: ['test/fixtures/src/*.css', '!test/fixtures/src/*.resorted.css'],
60+
ext: '.resorted.css'
5761
}
5862
},
5963

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,24 @@ grunt.initConfig({
101101
});
102102
```
103103

104+
#### Src Only
105+
106+
If you provide only a `src` with no value for `dest`, then `dest` will automatically be set to the `src` directory.
107+
108+
```js
109+
grunt.initConfig({
110+
csscomb: {
111+
src_only: {
112+
src: ['foo/bar.css'],
113+
ext: '.resorted.css'
114+
}
115+
}
116+
});
117+
```
118+
104119
## Release History
105120

121+
+ v4.0.0: Update csscomb.js to v4; update dependencies; allow src only.
106122
+ v3.1.1: Update grunt version.
107123
+ v3.0.0: Update csscomb.js to v3.0 but `grunt-csscomb` API doesn't change.
108124
+ v2.0.1: Stop searching config if we reach root directory.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "grunt-csscomb",
33
"description": "The grunt plugin for sorting CSS properties in specific order.",
4-
"version": "3.1.1",
4+
"version": "4.0.0",
55
"homepage": "https://github.com/csscomb/grunt-csscomb",
66
"author": [
77
{
@@ -37,22 +37,22 @@
3737
],
3838
"main": "Gruntfile.js",
3939
"engines": {
40-
"node": ">= 0.10.0"
40+
"node": ">= 6.0.0"
4141
},
4242
"scripts": {
4343
"test": "grunt test"
4444
},
4545
"dependencies": {
46-
"csscomb": "~3.1.0"
46+
"csscomb": "~4.2.0"
4747
},
4848
"devDependencies": {
49-
"grunt": "^0.4.5",
50-
"grunt-contrib-clean": "^0.6.0",
51-
"grunt-contrib-jshint": "^0.11.2",
52-
"grunt-contrib-nodeunit": "^0.4.1"
49+
"grunt": "^1.0.3",
50+
"grunt-contrib-clean": "^2.0.0",
51+
"grunt-contrib-jshint": "^2.0.0",
52+
"grunt-contrib-nodeunit": "^2.0.0"
5353
},
5454
"peerDependencies": {
55-
"grunt": ">=0.4.0"
55+
"grunt": ">=1.0.0"
5656
},
5757
"keywords": [
5858
"gruntplugin",

tasks/csscomb.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,21 @@ module.exports = function (grunt) {
7171
return true;
7272
}
7373
}).forEach(function (src) {
74+
var dest = f.dest,
75+
syntax = src.split('.').pop();
76+
if (!dest) {
77+
dest = grunt.file.expandMapping(src, '', { ext: f.ext || '.' + syntax })[0].dest;
78+
}
7479

7580
// Get CSS from a source file:
7681
var css = grunt.file.read(src);
77-
var combed;
7882

7983
// Comb it:
8084
grunt.log.ok('Sorting file "' + src + '"...');
81-
var syntax = src.split('.').pop();
8285
try {
83-
combed = comb.processString(css, { syntax: syntax });
84-
grunt.file.write(f.dest, combed);
86+
comb.processString(css, { syntax: syntax }).then(function(combed) {
87+
grunt.file.write(dest, combed);
88+
});
8589
} catch(e) {
8690
grunt.log.error(e);
8791
}

test/csscomb_test.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports.csscomb = {
88

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

1313
test.done();
1414
},
@@ -17,7 +17,7 @@ exports.csscomb = {
1717

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

2222
test.done();
2323
},
@@ -26,11 +26,11 @@ exports.csscomb = {
2626

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

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

3535
test.done();
3636
},
@@ -39,11 +39,24 @@ exports.csscomb = {
3939

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

4444
var actual2 = grunt.file.read('test/fixtures/dest/multi2.resorted.css');
4545
var expected2 = grunt.file.read('test/expected/multi2.css');
46-
test.equal(actual2, expected2, 'sholud be sorted.');
46+
test.equal(actual2, expected2, 'should be sorted.');
47+
48+
test.done();
49+
},
50+
src_only: function (test) {
51+
test.expect(2);
52+
53+
var actual = grunt.file.read('test/fixtures/src/multi1.resorted.css');
54+
var expected = grunt.file.read('test/expected/multi1.css');
55+
test.equal(actual, expected, 'should be sorted.');
56+
57+
var actual2 = grunt.file.read('test/fixtures/src/multi2.resorted.css');
58+
var expected2 = grunt.file.read('test/expected/multi2.css');
59+
test.equal(actual2, expected2, 'should be sorted.');
4760

4861
test.done();
4962
}

test/fixtures/src/multi1.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.multi1 {
2+
z-index: 100;
3+
display: block;
4+
visibility: hidden;
5+
max-height: 44px;
6+
width: 100px;
7+
height: 100px;
8+
border-color: 1px #000 solid;
9+
background-color: red;
10+
vertical-align: 5px;
11+
text-align: center;
12+
font-weight: bold;
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.multi1
2+
{
3+
font-weight: bold;
4+
5+
z-index: 100;
6+
7+
display: block;
8+
visibility: hidden;
9+
10+
width: 100px;
11+
height: 100px;
12+
max-height: 44px;
13+
14+
text-align: center;
15+
vertical-align: 5px;
16+
17+
border-color: 1px #000 solid;
18+
background-color: red;
19+
}

test/fixtures/src/multi2.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.multi2 {
2+
position: absolute;
3+
top: 10px;
4+
left: 10px;
5+
z-index: 10;
6+
display: table;
7+
float: left;
8+
margin: 10px;
9+
padding: 10px;
10+
width: 10px;
11+
height: 10px;
12+
border: 1px #fff solid;
13+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.multi2
2+
{
3+
position: absolute;
4+
z-index: 10;
5+
top: 10px;
6+
left: 10px;
7+
8+
display: table;
9+
float: left;
10+
11+
width: 10px;
12+
height: 10px;
13+
margin: 10px;
14+
padding: 10px;
15+
16+
border: 1px #fff solid;
17+
}

0 commit comments

Comments
 (0)