forked from tirejs/tire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrunt.js
79 lines (73 loc) · 1.94 KB
/
grunt.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*global module:false*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/*!\n' +
' * tire.js\n' +
' * Copyright (c) 2012-<%= grunt.template.today("yyyy") %> Fredrik Forsmo\n' +
' * Version: <%= pkg.version %>\n' +
' * Released under the MIT License.\n' +
' */'
},
concat: {
dist: {
src: ['<banner>', 'src/header.js', 'src/core.js', 'src/fn/*.js', 'src/footer.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
min: {
'dist/tire.min.js': [ '<banner>', 'dist/tire.js' ]
},
lint: {
files: ['src/core.js', 'src/fn/*.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint'
},
jshint: {
options: {
regexdash: true,
laxcomma: true,
expr: true,
eqeqeq: true,
noarg: true,
sub: true,
undef: true,
eqnull: true,
browser: true
},
globals: {
tire: true,
define: true,
slice: true,
document: true,
ActiveXObject: true
}
},
qunit: {
all: ['http://localhost:3000/']
}
});
grunt.registerMultiTask('concat', 'Fix indent for files', function () {
var src = ''
, dest = this.file.dest
, banner = grunt.task.directive(this.file.src[0], function() { return null; });
src += banner;
this.file.src.shift();
grunt.file.expandFiles(this.file.src).forEach(function (file) {
if (file.indexOf('header') !== -1 || file.indexOf('footer') !== -1) {
src += grunt.file.read(file) + '\n';
} else {
var lines = grunt.file.read(file).split('\n');
lines.forEach(function (line) {
src += ' ' + line + '\n';
});
}
grunt.file.write(dest, src);
});
grunt.log.writeln('File "' + dest + '" created.');
});
grunt.registerTask('default', 'concat min');
};