Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-banner

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-banner - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

.editorconfig

52

index.js
var postcss = require('postcss');
module.exports = postcss.plugin('postcss-banner', function (opts) {
opts = opts || {};
module.exports = postcss.plugin('postcss-banner', function configure(opts) {
opts = opts || {};
function process(value) {
var text = String(value);
var comment = postcss.comment({ text: text });
function process(value) {
var text = String(value);
var comment = text;
if (text.indexOf('*') === 0 || text.indexOf('!') === 0) {
comment.raws.left = '';
comment.raws.right = '';
}
return comment;
if (!opts.inline) {
comment = text.split('\n')
.join('\n * ')
.concat('\n ');
}
return function (css) {
if ('banner' in opts) {
css.prepend(process(opts.banner));
comment = ['/*', comment, '*/'].join('');
// New line after banner
if (css.nodes[1]) {
css.nodes[1].raws.before = '\n';
}
}
return comment;
}
if ('footer' in opts) {
var footer = process(opts.footer);
footer.raws.before = '\n';
return function andBanner(css) {
if ('banner' in opts) {
css.prepend(process(opts.banner));
css.append(footer);
}
};
// New line after banner
if (css.nodes[1]) {
css.nodes[1].raws.before = '\n';
}
}
if ('footer' in opts) {
var footer = process(opts.footer);
css.append(footer);
css.nodes[css.nodes.length - 1].raws.before = '\n';
}
};
});
{
"name": "postcss-banner",
"version": "1.2.0",
"version": "2.0.0",
"description": "PostCSS plugin to add text banner to resulting file",

@@ -23,7 +23,8 @@ "keywords": [

"chai": "^3.4.1",
"eslint": "^2.13.0",
"eslint-config-airbnb-base": "^3.0.1",
"eslint-plugin-import": "^1.8.1",
"gulp": "^3.9.0",
"gulp-jshint": "^2.0.0",
"gulp-eslint": "^2.0.0",
"gulp-mocha": "^2.0.0",
"jshint": "^2.9.1",
"jshint-stylish": "^2.0.0",
"mocha": "^2.1.0"

@@ -30,0 +31,0 @@ },

@@ -7,10 +7,24 @@ # PostCSS Banner [![Current version](https://img.shields.io/npm/v/postcss-banner.svg?style=flat-square)](https://www.npmjs.com/package/postcss-banner) [![Build Status](https://img.shields.io/travis/princed/postcss-banner.svg?style=flat-square)](https://travis-ci.org/princed/postcss-banner)

## Migration from version 1.x
* No spaces are added automatically
* Multi-line mode is default
* Asterisks in multi-line mode are added automatically
* Use `inline` to turn off multi-line mode
## Usage
Set `banner` and `footer` properties to add banner and/or footer to your resulting css (so use after minifier).
Add PostCSS Banner to your build tool:
```sh
npm install --save-dev postcss-banner
```
Set `banner` and `footer` properties to add banner and/or footer to your
resulting css (so use after minifier).
Example:
```js
postcss(require('postcss-banner')({banner: 'banner'}))
postcss(require('postcss-banner')({banner: '!\nbanner'}))
```

@@ -21,3 +35,5 @@

```css
/* banner */
/*!
* banner
*/
.foo {

@@ -28,12 +44,23 @@ }

Value will be converted to string and wrapped with spaces by default.
Add `*` or `!` as a first symbol to avoid wrapping in spaces (and achieve nice multi-line comments for instance).
Set `inline` to `true` to render the comment in a single line.
Example:
```js
postcss(require('postcss-banner')({banner: '*\n' +
' * multi\n' +
' * line\n' +
' * comment\n' +
' '}))
var postcss = require('gulp-postcss');
var postcssBanner = require('postcss-banner');
var banner = ' single line comment ';
gulp.task('css', function () {
return gulp.src('./css/src/*.css')
.pipe(postcss(
[
postcssBanner({
banner: banner,
inline: true
})
]))
.pipe(gulp.dest('./css'));
});
```

@@ -44,7 +71,3 @@

```css
/**
* multi
* line
* comment
*/
/* single line comment */
.foo {

@@ -54,2 +77,28 @@ }

See [PostCSS] docs for examples for your environment.
## Options
### `banner`
Type: `String`
The string will be converted in a css comment and put at the
beginning of the css file.
### `footer`
Type: `String`
The string will be converted in a css comment and put at the
end of the css file.
### `inline`
Type: `Boolean`
Render the banner all in one line
## License
[MIT License](https://github.com/princed/postcss-banner/blob/master/LICENSE) © Eugene Datsky
See [PostCSS](http://postcss.org/) docs for examples for your environment.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc