Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostCSS 8 support #31

Merged
merged 13 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [8, 14]
node: [10, 12, 14]

steps:
- name: Clone repository
Expand Down
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"esversion": 6,
"esversion": 8,
"curly": true,
"eqeqeq": true,
"expr": true,
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v3.0.0
date: 19-09-2020
changes:
- Updated to PostCSS 8
- Drop support for NodeJS 8, 11 and 13
v2.0.4
date: 12-05-2020
changes:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

This plugin requires Grunt `~1.0.3`

**Note:** As of v2.0.0, Node.js 8.x or above is required.
**Note:** As of v3.0.0, Node.js 10.x, 12.x or 14.x is required.

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

Expand Down
17 changes: 12 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lodder/grunt-postcss",
"version": "2.0.4",
"version": "3.0.0",
"description": "Apply several post-processors to your CSS using PostCSS",
"author": {
"name": "Dmitry Nikitenko",
Expand All @@ -9,7 +9,7 @@
"repository": "C-Lodder/grunt-postcss",
"license": "MIT",
"engines": {
"node": ">= 8"
"node": "^10 || ^12 || >=14"
},
"scripts": {
"test": "grunt test"
Expand All @@ -26,20 +26,20 @@
],
"dependencies": {
"diff": "^4.0.2",
"maxmin": "^3.0.0",
"postcss": "^8.0.5"
"maxmin": "^3.0.0"
},
"devDependencies": {
"@lodder/time-grunt": "^4.0.0",
"cssnano": "^4.1.10",
"grunt": "^1.1.0",
"grunt": "^1.3.0",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-jshint": "^2.1.0",
"grunt-contrib-nodeunit": "^2.1.0",
"load-grunt-tasks": "^5.1.0",
"postcss-scss": "^3.0.0"
},
"peerDependencies": {
"grunt": ">=1.0.4"
"grunt": ">=1.0.4",
"postcss": "^8.0.5"
}
}
3 changes: 2 additions & 1 deletion tasks/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ module.exports = (grunt) => {
prev: getPrevMap(from),
inline: (typeof options.map.inline === 'boolean') ? options.map.inline : true,
annotation: getAnnotation(to),
sourcesContent: (typeof options.map.sourcesContent === 'boolean') ? options.map.sourcesContent : true
sourcesContent: (typeof options.map.sourcesContent === 'boolean') ? options.map.sourcesContent : true,
absolute: (typeof options.map.absolute === 'boolean') ? options.map.absolute : false
},
from: from,
to: to,
Expand Down
100 changes: 61 additions & 39 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const grunt = require('grunt');
const { readFile, access } = require('fs').promises;

/*
======== A Handy Little Nodeunit Reference ========
Expand All @@ -20,122 +20,144 @@ const grunt = require('grunt');
test.ifError(value)
*/

const fileExists = async(file) => {
try {
await access(file);
return true;
} catch (error) {
return false;
}
};

exports.gruntPostcss = {

defaults: (test) => {
defaults: async(test) => {
const actual = {
css: grunt.file.read('tmp/defaults.css'),
css: await readFile('tmp/defaults.css', 'utf8'),
};

const expected = {
css: grunt.file.read('test/expected/defaults.css'),
css: await readFile('test/expected/defaults.css', 'utf8'),
};

test.strictEqual(actual.css, expected.css);
test.ok(!grunt.file.exists('tmp/defaults.css.map'));

const checkExists = await fileExists('tmp/defaults.css.map');
test.ok(!checkExists);
test.done();
},

defaultsFn: (test) => {
defaultsFn: async(test) => {
const actual = {
css: grunt.file.read('tmp/defaultsFn.css'),
css: await readFile('tmp/defaultsFn.css', 'utf8'),
};

const expected = {
css: grunt.file.read('test/expected/defaults.css'),
css: await readFile('test/expected/defaults.css', 'utf8'),
};

test.strictEqual(actual.css, expected.css);
test.ok(!grunt.file.exists('tmp/defaultsFn.css.map'));

const checkExists = await fileExists('tmp/defaultsFn.css.map');
test.ok(!checkExists);
test.done();
},

mapInline: (test) => {
mapInline: async(test) => {
const actual = {
css: grunt.file.read('tmp/mapInline.css'),
css: await readFile('tmp/mapInline.css', 'utf8'),
};

const expected = {
css: grunt.file.read('test/expected/mapInline.css'),
css: await readFile('test/expected/mapInline.css', 'utf8'),
};

test.strictEqual(actual.css, expected.css);
test.ok(!grunt.file.exists('tmp/mapInline.css.map'));

const checkExists = await fileExists('tmp/mapInline.css.map');
test.ok(!checkExists);
test.done();
},

mapSeparate: (test) => {
mapSeparate: async(test) => {
const actual = {
css: grunt.file.read('tmp/mapSeparate.css'),
map: grunt.file.read('tmp/mapSeparate.css.map'),
css: await readFile('tmp/mapSeparate.css', 'utf8'),
map: await readFile('tmp/mapSeparate.css.map', 'utf8'),
};

const expected = {
css: grunt.file.read('test/expected/mapSeparate.css'),
map: grunt.file.read('test/expected/mapSeparate.css.map'),
css: await readFile('test/expected/mapSeparate.css', 'utf8'),
map: await readFile('test/expected/mapSeparate.css.map', 'utf8'),
};

test.strictEqual(actual.css, expected.css);
test.strictEqual(actual.map, expected.map);
test.done();
},

mapAnnotationPath: (test) => {
mapAnnotationPath: async(test) => {
const actual = {
css: grunt.file.read('tmp/mapAnnotationPath.css'),
map: grunt.file.read('tmp/maps/mapAnnotationPath.css.map'),
css: await readFile('tmp/mapAnnotationPath.css', 'utf8'),
map: await readFile('tmp/maps/mapAnnotationPath.css.map', 'utf8'),
};

const expected = {
css: grunt.file.read('test/expected/mapAnnotationPath.css'),
map: grunt.file.read('test/expected/maps/mapAnnotationPath.css.map'),
css: await readFile('test/expected/mapAnnotationPath.css', 'utf8'),
map: await readFile('test/expected/maps/mapAnnotationPath.css.map', 'utf8'),
};

test.strictEqual(actual.css, expected.css);
test.strictEqual(actual.map, expected.map);
test.ok(!grunt.file.exists('tmp/mapAnnotationPath.css.map'));

const checkExists = await fileExists('tmp/mapAnnotationPath.css.map');
test.ok(!checkExists);
test.done();
},

diff: (test) => {
diff: async(test) => {
const actual = {
css: grunt.file.read('tmp/diff.css'),
map: grunt.file.read('tmp/diff.css.diff'),
css: await readFile('tmp/diff.css', 'utf8'),
map: await readFile('tmp/diff.css.diff', 'utf8'),
};

const expected = {
css: grunt.file.read('test/expected/diff.css'),
map: grunt.file.read('test/expected/diff.css.diff'),
css: await readFile('test/expected/diff.css', 'utf8'),
map: await readFile('test/expected/diff.css.diff', 'utf8'),
};

test.strictEqual(actual.css, expected.css);
test.strictEqual(actual.map, expected.map);
test.done();
},

syntax: (test) => {
syntax: async(test) => {
const actual = {
scss: grunt.file.read('tmp/syntax.scss'),
scss: await readFile('tmp/syntax.scss', 'utf8'),
};

const expected = {
scss: grunt.file.read('test/expected/syntax.scss'),
scss: await readFile('test/expected/syntax.scss', 'utf8'),
};

test.strictEqual(actual.scss, expected.scss);
test.done();
},

writeDest: (test) => {
test.ok(grunt.file.exists('tmp/doWriteDest.scss'));
test.ok(!grunt.file.exists('tmp/noWriteDest.scss'));
writeDest: async(test) => {
const checkExists = await fileExists('tmp/doWriteDest.scss');
test.ok(checkExists);

const checkNoExists = await fileExists('tmp/noWriteDest.scss');
test.ok(!checkNoExists);
test.done();
},

sequential: (test) => {
test.ok(grunt.file.exists('tmp/sequential.css'));
const actual = grunt.file.read('tmp/sequential.css');
const expected = grunt.file.read('test/fixtures/a.css');
sequential: async(test) => {
const checkExists = await fileExists('tmp/sequential.css');
test.ok(checkExists);

const actual = await readFile('tmp/sequential.css', 'utf8');
const expected = await readFile('test/fixtures/a.css', 'utf8');
test.strictEqual(actual, expected);
test.done();
},
Expand Down