Last change
on this file since 484 was
484,
checked in by hendrikvanantwerpen, 11 years ago
|
Commit node_modules, to make checkouts and builds more deterministic.
|
File size:
1.3 KB
|
Line | |
---|
1 | /* |
---|
2 | * grunt-banner |
---|
3 | * https://github.com/mattstyles/grunt-banner |
---|
4 | * |
---|
5 | * Copyright (c) 2013 Matt Styles |
---|
6 | * Licensed under the MIT license. |
---|
7 | */ |
---|
8 | |
---|
9 | 'use strict'; |
---|
10 | |
---|
11 | module.exports = function(grunt) { |
---|
12 | |
---|
13 | // Please see the Grunt documentation for more information regarding task |
---|
14 | // creation: http://gruntjs.com/creating-tasks |
---|
15 | |
---|
16 | grunt.registerMultiTask('usebanner', 'Adds a banner or a footer to a file', function() { |
---|
17 | // Set up defaults for the options hash |
---|
18 | var options = this.options({ |
---|
19 | position: 'top', |
---|
20 | banner: '' |
---|
21 | }); |
---|
22 | if ( options.position !== 'top' && options.position !== 'bottom' ) { |
---|
23 | options.position = 'top'; |
---|
24 | } |
---|
25 | |
---|
26 | // Iterate over the list of files and add the banner or footer |
---|
27 | this.files.forEach( function( file ) { |
---|
28 | file.src.forEach( function( src ) { |
---|
29 | |
---|
30 | if ( grunt.file.isFile( src ) ) { |
---|
31 | |
---|
32 | grunt.file.write( src, |
---|
33 | options.position === 'top' ? options.banner + '\n' + grunt.file.read( src ) : grunt.file.read( src ) + '\n' + options.banner |
---|
34 | ); |
---|
35 | |
---|
36 | grunt.log.writeln( 'Banner added to file ' + src.cyan ); |
---|
37 | } |
---|
38 | |
---|
39 | }); |
---|
40 | }); |
---|
41 | |
---|
42 | grunt.log.writeln( 'â'.magenta + ' grunt-banner completed successfully' ); |
---|
43 | |
---|
44 | }); |
---|
45 | |
---|
46 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.