Skip to content

Commit

Permalink
Update PostCSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Semigradsky committed May 15, 2017
1 parent 1326833 commit 9cc79b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -23,7 +23,7 @@
"!**/__tests__"
],
"dependencies": {
"postcss": "^5.2.0",
"postcss": "^6.0.1",
"postcss-value-parser": "^3.3.0"
},
"devDependencies": {
Expand Down
16 changes: 10 additions & 6 deletions src/index.js
Expand Up @@ -5,21 +5,25 @@ import functionalNotation from './lib/rgb-functional-notation';
function transformRgb(value) {
return parser(value).walk(node => {
/* istanbul ignore if */
if (node.type !== 'function' || (node.value !== 'rgb' && node.value !== 'rgba')) {
if (node.type !== 'function' ||
node.value !== 'rgb' &&
node.value !== 'rgba'
) {
return;
}
node.value = functionalNotation.legacy(parser.stringify(node));
node.type = 'word';
}).toString();
}

module.exports = postcss.plugin('postcss-color-rgb', function (opts) {
opts = opts || {};

return function (root, result) {
module.exports = postcss.plugin('postcss-color-rgb', function () {
return function (root) {
root.walkDecls(decl => {
/* istanbul ignore if */
if (!decl.value || (decl.value.indexOf('rgb(') === -1 && decl.value.indexOf('rgba(') === -1)) {
if (!decl.value ||
decl.value.indexOf('rgb(') === -1 &&
decl.value.indexOf('rgba(') === -1
) {
return;
}
decl.value = transformRgb(decl.value);
Expand Down

0 comments on commit 9cc79b7

Please sign in to comment.