source: Dev/trunk/node_modules/grunt-banner/README.md @ 533

Last change on this file since 533 was 484, checked in by hendrikvanantwerpen, 11 years ago

Commit node_modules, to make checkouts and builds more deterministic.

File size: 3.8 KB
RevLine 
[484]1# grunt-banner [![Build Status](https://travis-ci.org/mattstyles/grunt-banner.png?branch=master)](https://travis-ci.org/mattstyles/grunt-banner)
2
3> Adds a simple banner to files
4
5## Getting Started
6This plugin requires Grunt `~0.4.1`
7
8If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
9
10```shell
11npm install grunt-banner --save-dev
12```
13
14Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
15
16```js
17grunt.loadNpmTasks('grunt-banner');
18```
19
20Or if you are using [matchdep](https://github.com/tkellen/node-matchdep) it will be included along with other
21`grunt-*` tasks by using this line of JS:
22
23```js
24require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
25```
26
27## The "usebanner" task
28
29_grunt-banner renamed it’s task from `banner` to `usebanner` as a `banner` is often used to hold a banner template
30for a number of grunt plugins_
31
32### Overview
33In your project's Gruntfile, add a section named `usebanner` to the data object passed into `grunt.initConfig()`.
34
35The wildcard selector `*` is perfectly valid for selecting targets to add a banner to.
36
37```js
38grunt.initConfig({
39  usebanner: {
40    taskName: {
41      options: {
42        position: 'top' || 'bottom'
43        banner: '// banner text <%= templates encouraged %>'
44      },
45      files: {
46        src: [ 'path/to/file.ext', 'path/to/another/*.ext' ]
47      }
48    }
49  }
50})
51```
52
53### Options
54
55#### options.position
56Type: `String`
57Default value: `'top`
58Value range: `'top'` or `'bottom'` only
59
60The position to place the banner - _either_ the top or bottom (other values will default to top)
61
62#### options.banner
63Type: `String`
64Default value: ``
65
66The text to use as a banner.  Templated strings are perfectly acceptable and encouraged.
67
68### Usage Examples
69
70In this example an `appConfig` is read from a JSON file and used to populate a `banner` template which
71is then used by `grunt-banner` to place at the top of some files.  Each file in the array will have the
72banner placed on to it and all `.js` files in the `/more-scripts/` folder will have a banner thanks to
73the `*` wildcard.
74
75```js
76var appConfig = grunt.file.readJSON( 'app-config.json' ) || {};
77grunt.initConfig({
78  banner: '/* <%= appConfig.info.name %> - version <%= appConfig.info.version %> - ' +
79          '<%= grunt.template.today("dd-mm-yyyy") %>\n' +
80          '<%= appConfig.info.description %>\n ' +
81          '&#169 <%= grunt.template.today("yyyy") %> <%= appConfig.info.author.name %> ' +
82          '- <%= appConfig.info.author.email %> */\n',
83  usebanner: {
84    dist: {
85      options: {
86        position: 'top'
87        banner: '<%= banner %>'
88      },
89      files: {
90        src: [ 'scripts/main-min.js', 'stylesheets/main-min.css', 'more-scripts/*.js' ]
91      }
92    }
93  }
94})
95```
96
97### Notes
98
99`grunt-banner` simply adds the banner to the head or foot of the files that are specified by
100the array passed to `files.src`, it makes no attempt to see if a banner already exists and it
101is up to the user to ensure that the file should not already contain a banner.  To this end it is
102strongly recommended to use the [grunt-contrib-clean](https://github.com/gruntjs/grunt-contrib-clean)
103task and only add banners to production-ready code.
104
105## Contributing
106In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
107
108## Release History
109* 01.05.03 -- v0.1.4 -- Fix for wildcard selector
110* 01.05.13 -- v0.1.3 -- Added travis
111* 30.04.13 -- v0.1.0 -- Initial release of grunt-banner
Note: See TracBrowser for help on using the repository browser.