-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
159 lines (144 loc) · 4.35 KB
/
Gruntfile.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*global module:false, require:false*/
module.exports = function(grunt) {
'use strict';
// Load Deps
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Travis doesn't have chrome, so we need to overwrite some options
var testConfig = function(configFile, customOptions) {
var options = { configFile: configFile, keepalive: true };
var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' };
return grunt.util._.extend(options, customOptions, travisOptions);
};
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '###\n<%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("dd mmmm yyyy") %>\n' +
'<%= pkg.homepage ? pkg.homepage + "\\n" : "" %>' +
'Copyright (c) <%= grunt.template.today("yyyy") %> n3-charts' +
'\n###\n',
bannerjs: '/*\n<%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("dd mmmm yyyy") %>\n' +
'<%= pkg.homepage ? pkg.homepage + "\\n" : "" %>' +
'Copyright (c) <%= grunt.template.today("yyyy") %> n3-charts' +
'\n*/\n',
watch: {
files: ['lib/**/*.coffee', 'test/unit/**/*.mocha.coffee'],
tasks: ['concat', 'coffeelint', 'coffee', 'karma:unminified', 'uglify', 'karma:minified'],
// tasks: ['concat', 'coffee', 'uglify']
},
karma: {
options: testConfig('karma.conf.js'),
unminified: {
singleRun: true,
autoWatch: false,
browsers: ['Firefox', 'Chrome'],
options: {
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/d3/d3.js',
'dist/line-chart.js',
'test/unit/**/*.coffee'
],
preprocessors: {
'dist/line-chart.js': 'coverage',
'test/unit/**/*.coffee': 'coffee'
}
}
},
minified: {
singleRun: true,
autoWatch: false,
browsers: ['Firefox', 'Chrome'],
options: {
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/d3/d3.js',
'dist/line-chart.min.js',
'test/unit/**/*.coffee'
],
preprocessors: {
'test/unit/**/*.coffee': 'coffee'
},
reporters: ['dots'],
}
}
},
concat: {
utils: {
src: ['lib/utils/*.coffee'],
dest: '/tmp/utils.coffee',
options: {
banner: grunt.file.read('lib/utils/utils.coffee.prefix'),
footer: grunt.file.read('lib/utils/utils.coffee.suffix'),
separator: '\n\n',
process: function(src, filepath) {
return '# ' + filepath + '\n' + src + '\n# ----\n';
}
}
},
js: {
options: {
banner: '<%= banner %>',
stripBanners: true,
process: function(src, filepath) {
return '# ' + filepath + '\n' + src + '\n# ----\n';
}
},
src: ['lib/<%= pkg.name %>.coffee', '/tmp/utils.coffee'],
dest: 'dist/<%= pkg.name %>.coffee'
}
},
coffeelint: {
app: ['dist/<%= pkg.name %>.coffee'],
options: {
'max_line_length': {
'level': 'ignore'
}
}
},
coffee: {
options: {
bare: true
},
compile: {
files: {
'dist/<%= pkg.name %>.js': 'dist/<%= pkg.name %>.coffee'
}
}
},
uglify: {
options: {
banner: '<%= bannerjs %>'
},
js: {
src: 'dist/<%= pkg.name %>.js',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
test: {
src: ['lib/*.js']
}
},
shell: {
visual: {
options: {},
command: './test/visual/scripts/run.py'
}
}
});
// Default task.
grunt.registerTask('travis', ['default', 'shell:visual']);
grunt.registerTask('visual', ['concat', 'coffeelint', 'coffee', 'uglify', 'shell:visual']);
grunt.registerTask('default', ['concat', 'coffeelint', 'coffee', 'uglify', 'karma:minified']);
};