diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b51b98c..c3bda05 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - node: [8, 14] + node: [10, 12, 14] steps: - name: Clone repository diff --git a/.jshintrc b/.jshintrc index 69e76d3..8214772 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,5 +1,5 @@ { - "esversion": 6, + "esversion": 8, "curly": true, "eqeqeq": true, "expr": true, diff --git a/CHANGELOG b/CHANGELOG index 2533470..db42076 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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: diff --git a/README.md b/README.md index 91f0f2d..a527607 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/package-lock.json b/package-lock.json index 357e372..ca0c238 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@lodder/grunt-postcss", - "version": "2.0.4", + "version": "3.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -802,7 +802,8 @@ "colorette": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", - "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==" + "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==", + "dev": true }, "colors": { "version": "1.1.2", @@ -2976,6 +2977,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/line-column/-/line-column-1.0.2.tgz", "integrity": "sha1-0lryk2tvSEkXKzEuR5LR2Ye8NKI=", + "dev": true, "requires": { "isarray": "^1.0.0", "isobject": "^2.0.0" @@ -2984,12 +2986,14 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true }, "isobject": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, "requires": { "isarray": "1.0.0" } @@ -3307,7 +3311,8 @@ "nanoid": { "version": "3.1.12", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.12.tgz", - "integrity": "sha512-1qstj9z5+x491jfiC4Nelk+f8XBad7LN20PmyWINJEMRSf3wcAjAWysw1qaA8z6NSKe2sjq1hRSDpBH5paCb6A==" + "integrity": "sha512-1qstj9z5+x491jfiC4Nelk+f8XBad7LN20PmyWINJEMRSf3wcAjAWysw1qaA8z6NSKe2sjq1hRSDpBH5paCb6A==", + "dev": true }, "nanomatch": { "version": "1.2.13", @@ -3846,6 +3851,7 @@ "version": "8.0.5", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.0.5.tgz", "integrity": "sha512-3rDm6KR0jHstte3aL3ugrCyFA1UXY90SWNwRZ2WTmRf/QpOqM35mm0FrRR+HHZQ5fY9+nXFat1nl2ekYJf0P4w==", + "dev": true, "requires": { "colorette": "^1.2.1", "line-column": "^1.0.2", @@ -6191,7 +6197,8 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true }, "source-map-resolve": { "version": "0.5.3", diff --git a/package.json b/package.json index c8c0271..9d9e2d8 100644 --- a/package.json +++ b/package.json @@ -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", @@ -9,7 +9,7 @@ "repository": "C-Lodder/grunt-postcss", "license": "MIT", "engines": { - "node": ">= 8" + "node": "^10 || ^12 || >=14" }, "scripts": { "test": "grunt test" @@ -26,13 +26,12 @@ ], "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", @@ -40,6 +39,7 @@ "postcss-scss": "^3.0.0" }, "peerDependencies": { - "grunt": ">=1.0.4" + "grunt": ">=1.0.4", + "postcss": "^8.0.5" } } diff --git a/tasks/postcss.js b/tasks/postcss.js index c56616e..ea765a7 100644 --- a/tasks/postcss.js +++ b/tasks/postcss.js @@ -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, diff --git a/test/test.js b/test/test.js index 66d8285..e4dba80 100644 --- a/test/test.js +++ b/test/test.js @@ -1,4 +1,4 @@ -const grunt = require('grunt'); +const { readFile, access } = require('fs').promises; /* ======== A Handy Little Nodeunit Reference ======== @@ -20,59 +20,74 @@ 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); @@ -80,32 +95,34 @@ exports.gruntPostcss = { 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); @@ -113,29 +130,34 @@ exports.gruntPostcss = { 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(); },