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

Port to PostCSS 8 API. #71

Merged
merged 2 commits into from
Oct 31, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sudo: false
language: node_js
node_js:
- 10
- 14
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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