Skip to content

Commit 689cb49

Browse files
committed
PostCSS 8 support
1 parent f9ba640 commit 689cb49

File tree

7 files changed

+87
-53
lines changed

7 files changed

+87
-53
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
node: [8, 14]
14+
node: [14]
1515

1616
steps:
1717
- name: Clone repository

.jshintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"esversion": 6,
2+
"esversion": 8,
33
"curly": true,
44
"eqeqeq": true,
55
"expr": true,

CHANGELOG

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v3.0.0
2+
date: 19-09-2020
3+
changes:
4+
- Updated PostCSS to 8.0.5
5+
- Drop support for NodeJS 8, 11 and 13
16
v2.0.4
27
date: 12-05-2020
38
changes:

Gruntfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = (grunt) => {
6565
options: {
6666
map: {
6767
inline: false,
68-
annotation: 'tmp/maps/'
68+
annotation: '/tmp/maps/'
6969
},
7070
processors: processors
7171
},

package-lock.json

+12-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lodder/grunt-postcss",
3-
"version": "2.0.4",
3+
"version": "3.0.0",
44
"description": "Apply several post-processors to your CSS using PostCSS",
55
"author": {
66
"name": "Dmitry Nikitenko",
@@ -9,7 +9,7 @@
99
"repository": "C-Lodder/grunt-postcss",
1010
"license": "MIT",
1111
"engines": {
12-
"node": ">= 8"
12+
"node": ">= 14"
1313
},
1414
"scripts": {
1515
"test": "grunt test"
@@ -26,20 +26,20 @@
2626
],
2727
"dependencies": {
2828
"diff": "^4.0.2",
29-
"maxmin": "^3.0.0",
30-
"postcss": "^8.0.5"
29+
"maxmin": "^3.0.0"
3130
},
3231
"devDependencies": {
3332
"@lodder/time-grunt": "^4.0.0",
3433
"cssnano": "^4.1.10",
35-
"grunt": "^1.1.0",
34+
"grunt": "^1.3.0",
3635
"grunt-contrib-clean": "^2.0.0",
3736
"grunt-contrib-jshint": "^2.1.0",
3837
"grunt-contrib-nodeunit": "^2.1.0",
3938
"load-grunt-tasks": "^5.1.0",
4039
"postcss-scss": "^3.0.0"
4140
},
4241
"peerDependencies": {
43-
"grunt": ">=1.0.4"
42+
"grunt": ">=1.0.4",
43+
"postcss": "^8.0.5"
4444
}
4545
}

test/test.js

+61-39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const grunt = require('grunt');
1+
const fs = require('fs');
2+
const { readFile, access } = fs.promises;
23

34
/*
45
======== A Handy Little Nodeunit Reference ========
@@ -20,122 +21,143 @@ const grunt = require('grunt');
2021
test.ifError(value)
2122
*/
2223

24+
const fileExists = async(file) => {
25+
try {
26+
await access(file);
27+
return true;
28+
} catch (err) {
29+
return false;
30+
}
31+
};
32+
2333
exports.gruntPostcss = {
2434

25-
defaults: (test) => {
35+
defaults: async(test) => {
2636
const actual = {
27-
css: grunt.file.read('tmp/defaults.css'),
37+
css: await readFile('tmp/defaults.css', 'utf8'),
2838
};
2939

3040
const expected = {
31-
css: grunt.file.read('test/expected/defaults.css'),
41+
css: await readFile('test/expected/defaults.css', 'utf8'),
3242
};
3343

44+
const checkExists = await fileExists('tmp/defaults.css.map');
45+
3446
test.strictEqual(actual.css, expected.css);
35-
test.ok(!grunt.file.exists('tmp/defaults.css.map'));
47+
test.ok(!checkExists);
3648
test.done();
3749
},
3850

39-
defaultsFn: (test) => {
51+
defaultsFn: async(test) => {
4052
const actual = {
41-
css: grunt.file.read('tmp/defaultsFn.css'),
53+
css: await readFile('tmp/defaultsFn.css', 'utf8'),
4254
};
4355

4456
const expected = {
45-
css: grunt.file.read('test/expected/defaults.css'),
57+
css: await readFile('test/expected/defaults.css', 'utf8'),
4658
};
4759

60+
const checkExists = await fileExists('tmp/defaultsFn.css.map');
61+
4862
test.strictEqual(actual.css, expected.css);
49-
test.ok(!grunt.file.exists('tmp/defaultsFn.css.map'));
63+
test.ok(!checkExists);
5064
test.done();
5165
},
5266

53-
mapInline: (test) => {
67+
mapInline: async(test) => {
5468
const actual = {
55-
css: grunt.file.read('tmp/mapInline.css'),
69+
css: await readFile('tmp/mapInline.css', 'utf8'),
5670
};
5771

5872
const expected = {
59-
css: grunt.file.read('test/expected/mapInline.css'),
73+
css: await readFile('test/expected/mapInline.css', 'utf8'),
6074
};
6175

76+
const checkExists = await fileExists('tmp/mapInline.css.map');
77+
6278
test.strictEqual(actual.css, expected.css);
63-
test.ok(!grunt.file.exists('tmp/mapInline.css.map'));
79+
test.ok(!checkExists);
6480
test.done();
6581
},
6682

67-
mapSeparate: (test) => {
83+
mapSeparate: async(test) => {
6884
const actual = {
69-
css: grunt.file.read('tmp/mapSeparate.css'),
70-
map: grunt.file.read('tmp/mapSeparate.css.map'),
85+
css: await readFile('tmp/mapSeparate.css', 'utf8'),
86+
map: await readFile('tmp/mapSeparate.css.map', 'utf8'),
7187
};
7288

7389
const expected = {
74-
css: grunt.file.read('test/expected/mapSeparate.css'),
75-
map: grunt.file.read('test/expected/mapSeparate.css.map'),
90+
css: await readFile('test/expected/mapSeparate.css', 'utf8'),
91+
map: await readFile('test/expected/mapSeparate.css.map', 'utf8'),
7692
};
7793

7894
test.strictEqual(actual.css, expected.css);
7995
test.strictEqual(actual.map, expected.map);
8096
test.done();
8197
},
8298

83-
mapAnnotationPath: (test) => {
99+
mapAnnotationPath: async(test) => {
84100
const actual = {
85-
css: grunt.file.read('tmp/mapAnnotationPath.css'),
86-
map: grunt.file.read('tmp/maps/mapAnnotationPath.css.map'),
101+
css: await readFile('tmp/mapAnnotationPath.css', 'utf8'),
102+
map: await readFile('tmp/maps/mapAnnotationPath.css.map', 'utf8'),
87103
};
88104

89105
const expected = {
90-
css: grunt.file.read('test/expected/mapAnnotationPath.css'),
91-
map: grunt.file.read('test/expected/maps/mapAnnotationPath.css.map'),
106+
css: await readFile('test/expected/mapAnnotationPath.css', 'utf8'),
107+
map: await readFile('test/expected/maps/mapAnnotationPath.css.map', 'utf8'),
92108
};
93109

110+
const checkExists = await fileExists('tmp/mapAnnotationPath.css.map');
111+
94112
test.strictEqual(actual.css, expected.css);
95113
test.strictEqual(actual.map, expected.map);
96-
test.ok(!grunt.file.exists('tmp/mapAnnotationPath.css.map'));
114+
test.ok(!checkExists);
97115
test.done();
98116
},
99117

100-
diff: (test) => {
118+
diff: async(test) => {
101119
const actual = {
102-
css: grunt.file.read('tmp/diff.css'),
103-
map: grunt.file.read('tmp/diff.css.diff'),
120+
css: await readFile('tmp/diff.css', 'utf8'),
121+
map: await readFile('tmp/diff.css.diff', 'utf8'),
104122
};
105123

106124
const expected = {
107-
css: grunt.file.read('test/expected/diff.css'),
108-
map: grunt.file.read('test/expected/diff.css.diff'),
125+
css: await readFile('test/expected/diff.css', 'utf8'),
126+
map: await readFile('test/expected/diff.css.diff', 'utf8'),
109127
};
110128

111129
test.strictEqual(actual.css, expected.css);
112130
test.strictEqual(actual.map, expected.map);
113131
test.done();
114132
},
115133

116-
syntax: (test) => {
134+
syntax: async(test) => {
117135
const actual = {
118-
scss: grunt.file.read('tmp/syntax.scss'),
136+
scss: await readFile('tmp/syntax.scss', 'utf8'),
119137
};
120138

121139
const expected = {
122-
scss: grunt.file.read('test/expected/syntax.scss'),
140+
scss: await readFile('test/expected/syntax.scss', 'utf8'),
123141
};
124142

125143
test.strictEqual(actual.scss, expected.scss);
126144
test.done();
127145
},
128146

129-
writeDest: (test) => {
130-
test.ok(grunt.file.exists('tmp/doWriteDest.scss'));
131-
test.ok(!grunt.file.exists('tmp/noWriteDest.scss'));
147+
writeDest: async(test) => {
148+
const checkExists = await fileExists('tmp/doWriteDest.css');
149+
const checkNoExists = await fileExists('tmp/noWriteDest.css');
150+
test.ok(checkExists);
151+
test.ok(!checkNoExists);
132152
test.done();
133153
},
134154

135-
sequential: (test) => {
136-
test.ok(grunt.file.exists('tmp/sequential.css'));
137-
const actual = grunt.file.read('tmp/sequential.css');
138-
const expected = grunt.file.read('test/fixtures/a.css');
155+
sequential: async(test) => {
156+
const checkExists = await fileExists('tmp/sequential.css');
157+
test.ok(checkExists);
158+
159+
const actual = await readFile('tmp/sequential.css', 'utf8');
160+
const expected = await readFile('test/fixtures/a.css', 'utf8');
139161
test.strictEqual(actual, expected);
140162
test.done();
141163
},

0 commit comments

Comments
 (0)