ca43fd913238bc5d900ff8281b5b107e663835e5.svn-base
1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* grunt
* http://gruntjs.com/
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
*/
module.exports = function(grunt) {
// ==========================================================================
// TASKS
// ==========================================================================
grunt.registerMultiTask('concat', 'Concatenate files.', function() {
var files = grunt.file.expandFiles(this.file.src);
// Concat specified files.
var src = grunt.helper('concat', files, {separator: this.data.separator});
grunt.file.write(this.file.dest, src);
// Fail task if errors were logged.
if (this.errorCount) { return false; }
// Otherwise, print a success message.
grunt.log.writeln('File "' + this.file.dest + '" created.');
});
// ==========================================================================
// HELPERS
// ==========================================================================
// Concat source files and/or directives.
grunt.registerHelper('concat', function(files, options) {
options = grunt.utils._.defaults(options || {}, {
separator: grunt.utils.linefeed
});
return files ? files.map(function(filepath) {
return grunt.task.directive(filepath, grunt.file.read);
}).join(grunt.utils.normalizelf(options.separator)) : '';
});
};