Skip to content

Commit

Permalink
👽 Update code structure for PostCSS Version 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Winston committed Sep 16, 2020
1 parent 454c4cc commit 867e92d
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
getNodesBySelectors
} = require('./utilities/selectors.js')

module.exports = postcss.plugin('postcss-sparrow', ({
module.exports = ({
transformations
}) => {
const options = {
Expand All @@ -29,17 +29,21 @@ module.exports = postcss.plugin('postcss-sparrow', ({
addComparatorFnToSelectors
)(options.transformations)

return (root, result) => {
R.map(
(transformation) => root.walkDecls((decl) => {
const result = R.when(
R.pipe(
R.prop('parent'),
getNodesBySelectors(transformation)
),
R.juxt(transformation.callbacks)
)(decl)
})
)(validatedTransformations)
return {
postcssPlugin: 'postcss-sparrow',
Root (root, result) {
R.map(
(transformation) => root.walkDecls((decl) => {
const result = R.when(
R.pipe(
R.prop('parent'),
getNodesBySelectors(transformation)
),
R.juxt(transformation.callbacks)
)(decl)
})
)(validatedTransformations)
}
}
})
}
module.exports.postcss = true

0 comments on commit 867e92d

Please sign in to comment.