postcss-banner
Advanced tools
Comparing version 3.0.1 to 3.0.2
32
index.js
@@ -1,22 +0,13 @@ | ||
var postcss = require('postcss'); | ||
const postcss = require('postcss'); | ||
module.exports = postcss.plugin('postcss-banner', function configure(opts) { | ||
opts = opts || {}; | ||
module.exports = postcss.plugin('postcss-banner', (opts = {}) => { | ||
function makeComment(banner) { | ||
const bang = opts.important ? '!' : ''; | ||
function process(value) { | ||
var comment = String(value); | ||
var bang = opts.important ? '!' : ''; | ||
if (opts.inline) { | ||
comment = ['', | ||
comment, | ||
'' | ||
].join(' '); | ||
} else { | ||
comment = [].concat('', comment.split('\n')) | ||
.join('\n * ') | ||
.concat('\n '); | ||
return `/*${bang} ${banner} */`; | ||
} | ||
return ['/*', bang, comment, '*/'].join(''); | ||
return `/*${bang} | ||
${banner.replace(/^|\n/g, '$& * ')} | ||
*/`; | ||
} | ||
@@ -26,6 +17,7 @@ | ||
if ('banner' in opts) { | ||
css.prepend(process(opts.banner)); | ||
css.prepend(makeComment(opts.banner)); | ||
// New line after banner | ||
if (css.nodes[1]) { | ||
// eslint-disable-next-line no-param-reassign | ||
css.nodes[1].raws.before = '\n'; | ||
@@ -36,4 +28,4 @@ } | ||
if ('footer' in opts) { | ||
var footer = process(opts.footer); | ||
css.append(footer); | ||
css.append(makeComment(opts.footer)); | ||
// eslint-disable-next-line no-param-reassign | ||
css.nodes[css.nodes.length - 1].raws.before = '\n'; | ||
@@ -40,0 +32,0 @@ } |
{ | ||
"name": "postcss-banner", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "PostCSS plugin to add text banner to resulting file", | ||
@@ -25,7 +25,8 @@ "keywords": [ | ||
"devDependencies": { | ||
"chai": "^4.1.0", | ||
"eslint": "^5.12.1", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.1.0", | ||
"mocha": "^5.2.0" | ||
"chai": "^4.2.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^14.1.0", | ||
"eslint-plugin-import": "^2.20.2", | ||
"mocha": "^7.1.1", | ||
"prettier": "^2.0.4" | ||
}, | ||
@@ -32,0 +33,0 @@ "scripts": { |
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
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
5112
6
27