Skip to content

Commit

Permalink
Port to PostCSS 8 API. (#71)
Browse files Browse the repository at this point in the history
* Port to PostCSS 8 API.

* 5.0.0

Co-authored-by: Luis Rudge <luis@luisrudge.net>
  • Loading branch information
ludofischer and luisrudge committed Oct 31, 2020
1 parent 5eb09c7 commit ff3e5a2
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 276 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,4 +1,4 @@
sudo: false
language: node_js
node_js:
- 10
- 14
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
## 5.0.0
* upgrade to postcss 8 [#71](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/71)

## 4.2.1
* Fix `calc` regex [#69](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/69)

Expand Down
54 changes: 29 additions & 25 deletions index.js
@@ -1,4 +1,3 @@
var postcss = require('postcss');
var bug4 = require('./bugs/bug4');
var bug6 = require('./bugs/bug6');
var bug81a = require('./bugs/bug81a');
Expand All @@ -12,30 +11,35 @@ var doNothingValues = [
'unset'
];

module.exports = postcss.plugin('postcss-flexbugs-fixes', function(opts) {
module.exports = function(opts) {
var options = Object.assign({ bug4: true, bug6: true, bug81a: true }, opts);

return function(css) {
css.walkDecls(function(d) {
if (d.value.indexOf('var(') > -1) {
return;
}
if (d.value === 'none') {
return;
}
var values = postcss.list.space(d.value);
if (doNothingValues.indexOf(d.value) > 0 && values.length === 1) {
return;
}
if (options.bug4) {
bug4(d);
}
if (options.bug6) {
bug6(d);
}
if (options.bug81a) {
bug81a(d);
}
});
return {
postcssPlugin: 'postcss-flexbugs-fixes',
Once: function(css, postcss) {
css.walkDecls(function(d) {
if (d.value.indexOf('var(') > -1) {
return;
}
if (d.value === 'none') {
return;
}
var values = postcss.list.space(d.value);
if (doNothingValues.indexOf(d.value) > 0 && values.length === 1) {
return;
}
if (options.bug4) {
bug4(d);
}
if (options.bug6) {
bug6(d);
}
if (options.bug81a) {
bug81a(d);
}
})
}
};
});
};

module.exports.postcss = true;
8 changes: 3 additions & 5 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "postcss-flexbugs-fixes",
"version": "4.2.1",
"version": "5.0.0",
"description": "PostCSS plugin This project tries to fix all of flexbug's issues",
"keywords": [
"postcss",
Expand All @@ -15,16 +15,14 @@
"repository": {
"type": "git",
"url": "https://github.com/luisrudge/postcss-flexbugs-fixes.git"
},
"dependencies": {
"postcss": "^7.0.26"
},
},
"main": "index.js",
"files": [
"bugs",
"index.js"
],
"devDependencies": {
"postcss": "^8.1.4",
"chai": "^4.2.0",
"gulp": "^4.0.2",
"gulp-eslint": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion specs/test.js
Expand Up @@ -4,7 +4,7 @@ var plugin = require('../');

module.exports = function(input, output, opts, done) {
postcss([plugin(opts)])
.process(input)
.process(input, {from: undefined})
.then(function(result) {
expect(result.css).to.eql(output);
expect(result.warnings()).to.be.empty;
Expand Down

0 comments on commit ff3e5a2

Please sign in to comment.