posthtml-postcss
Advanced tools
Comparing version 0.3.0 to 0.4.0
60
index.js
@@ -1,33 +0,33 @@ | ||
var postcss = require('postcss') | ||
const postcss = require('postcss'); | ||
module.exports = function (plugins, options, filterType) { | ||
plugins = [].concat(plugins).filter(plugin => typeof plugin === 'function') | ||
options = options || {} | ||
plugins = [].concat(plugins).filter(Boolean); | ||
options = options || {}; | ||
var css = postcss(plugins) | ||
const css = postcss(plugins); | ||
return function posthtmlPostcss (tree) { | ||
var promises = [] | ||
return function (tree) { | ||
const promises = []; | ||
tree.walk(function (node) { | ||
var promise | ||
tree.walk(node => { | ||
let promise; | ||
if (node.tag === 'style' && node.content) { | ||
var meetsFilter = true | ||
let meetsFilter = true; | ||
if (filterType) { | ||
var typeAttr = (node.attrs && node.attrs.type) ? node.attrs.type.trim() : '' | ||
var meetsTypeAttr = filterType.test(typeAttr) | ||
var meetsStandardType = filterType.test('text/css') && (meetsTypeAttr || typeAttr === '') | ||
var meetsOtherType = !meetsStandardType && meetsTypeAttr | ||
meetsFilter = meetsStandardType || meetsOtherType | ||
const typeAttr = (node.attrs && node.attrs.type) ? node.attrs.type.trim() : ''; | ||
const meetsTypeAttr = filterType.test(typeAttr); | ||
const meetsStandardType = filterType.test('text/css') && (meetsTypeAttr || typeAttr === ''); | ||
const meetsOtherType = !meetsStandardType && meetsTypeAttr; | ||
meetsFilter = meetsStandardType || meetsOtherType; | ||
} | ||
if (meetsFilter) { | ||
var styles = [].concat(node.content).join('') | ||
const styles = [].concat(node.content).join(''); | ||
promise = css.process(styles, options) | ||
.then(function (result) { | ||
node.content = [result.css] | ||
}) | ||
.then(result => { | ||
node.content = [result.css]; | ||
}); | ||
promises.push(promise) | ||
promises.push(promise); | ||
} | ||
@@ -38,16 +38,16 @@ } | ||
promise = css.process(node.attrs.style, options) | ||
.then(function (result) { | ||
node.attrs.style = result.css | ||
}) | ||
.then(result => { | ||
node.attrs.style = result.css; | ||
}); | ||
promises.push(promise) | ||
promises.push(promise); | ||
} | ||
return node | ||
}) | ||
return node; | ||
}); | ||
return Promise.all(promises).then(function () { | ||
return tree | ||
}) | ||
} | ||
} | ||
return Promise.all(promises).then(() => { | ||
return tree; | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "posthtml-postcss", | ||
"version": "0.3.0", | ||
"description": "PostHTML-PostCSS plugin. Use PostCSS in HTML document.", | ||
"version": "0.4.0", | ||
"description": "PostHTML-PostCSS plugin. Use PostCSS in HTML document", | ||
"license": "MIT", | ||
"repository": "posthtml/posthtml-postcss", | ||
"author": "Ivan Voischev <voischev.ivan@ya.ru>", | ||
"main": "index.js", | ||
"files": ["index.js"], | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
"test": "npm run lint && npm run coverage", | ||
"version": "conventional-changelog -i changelog.md -s -r 0 && git add changelog.md", | ||
"test": "c8 mocha --timeout 5000", | ||
"lint": "eslint {test/*,*}.js", | ||
"coverage": "istanbul cover --report text --report html --report lcov node_modules/mocha/bin/_mocha", | ||
"preversion": "npm test", | ||
"postversion": "git push && git push --tags && rm -rf coverage" | ||
"pretest": "clinton" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/posthtml/posthtml-postcss.git" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
@@ -33,36 +36,19 @@ "posthtml", | ||
], | ||
"author": "Ivan Voischev <voischev.ivan@ya.ru>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/posthtml/posthtml-postcss/issues" | ||
"dependencies": { | ||
"postcss": "^8.0.0" | ||
}, | ||
"homepage": "https://github.com/posthtml/posthtml-postcss#readme", | ||
"devDependencies": { | ||
"autoprefixer": "^9.6.5", | ||
"@commitlint/cli": "^11.0.0", | ||
"@commitlint/config-angular": "^11.0.0", | ||
"autoprefixer": "^10.0.2", | ||
"c8": "^7.3.5", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.5.1", | ||
"eslint-config-standard": "^14.1.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"istanbul": "^0.4.0", | ||
"mocha": "^6.2.2", | ||
"posthtml": "^0.12.0" | ||
}, | ||
"dependencies": { | ||
"postcss": "^7.0.18" | ||
}, | ||
"eslintConfig": { | ||
"env": { | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"plugins": [ | ||
"standard" | ||
], | ||
"extends": [ | ||
"standard" | ||
] | ||
"clinton": "^0.14.0", | ||
"conventional-changelog-cli": "^2.1.1", | ||
"husky": "^4.3.0", | ||
"lint-staged": "^10.5.1", | ||
"mocha": "^8.2.1", | ||
"posthtml": "^0.13.4", | ||
"xo": "^0.34.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14950
5
12
1
2
1
+ Addednanoid@3.3.8(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpostcss@8.4.49(transitive)
+ Addedsource-map-js@1.2.1(transitive)
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedsource-map@0.6.1(transitive)
Updatedpostcss@^8.0.0