This repository has been archived by the owner on May 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 355
/
grunt.js
143 lines (125 loc) · 4.35 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
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
var testacular = require('testacular');
/*global module:false*/
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-recess');
// Project configuration.
grunt.initConfig({
dist: 'build',
pkg: '<json:package.json>',
meta: {
banner: ['/**',
' * <%= pkg.description %>',
' * @version v<%= pkg.version %> - ',
'<%= grunt.template.today("yyyy-mm-dd") %>',
' * @link <%= pkg.homepage %>',
' * @license MIT License, http://www.opensource.org/licenses/MIT',
' */'].join('\n')
},
concat: {
build: {
src: ['<banner:meta.banner>', 'common/*.js'],
dest: '<%= dist %>/<%= pkg.name %>.js'
},
ieshiv: {
src: ['<banner:meta.banner>', 'common/ieshiv/*.js'],
dest: '<%= dist %>/<%= pkg.name %>-ieshiv.js'
}
},
min: {
build: {
src: ['<banner:meta.banner>', '<config:concat.build.dest>'],
dest: '<%= dist %>/<%= pkg.name %>.min.js'
},
ieshiv: {
src: ['<banner:meta.banner>', '<config:concat.ieshiv.dest>'],
dest: '<%= dist %>/<%= pkg.name %>-ieshiv.min.js'
}
},
recess: {
build: {
src: ['common/**/*.less'],
dest: '<%= dist %>/<%= pkg.name %>.css',
options: {
compile: true
}
},
min: {
src: '<config:recess.build.dest>',
dest: '<%= dist %>/<%= pkg.name %>.min.css',
options: {
compress: true
}
}
},
lint: {
files: ['grunt.js', 'common/**/*.js', 'modules/**/*.js']
},
watch: {
files: ['modules/**/*.js', 'common/**/*.js', 'templates/**/*.js'],
tasks: 'build test'
}
});
// Default task.
grunt.registerTask('default', 'build test');
grunt.registerTask('build', 'build all or some of the angular-ui modules', function () {
var jsBuildFiles = grunt.config('concat.build.src');
var lessBuildFiles = [];
if (this.args.length > 0) {
this.args.forEach(function(moduleName) {
var modulejs = grunt.file.expandFiles('modules/*/' + moduleName + '/*.js');
var moduleless = grunt.file.expandFiles('modules/*/' + moduleName + '/stylesheets/*.less', 'modules/*/' + moduleName + '/*.less');
jsBuildFiles = jsBuildFiles.concat(modulejs);
lessBuildFiles = lessBuildFiles.concat(moduleless);
});
grunt.config('concat.build.src', jsBuildFiles);
grunt.config('recess.build.src', lessBuildFiles);
} else {
grunt.config('concat.build.src', jsBuildFiles.concat(['modules/*/*/*.js']));
grunt.config('recess.build.src', lessBuildFiles.concat(grunt.config('recess.build.src')));
}
grunt.task.run('concat min recess:build recess:min');
});
grunt.registerTask('dist', 'change dist location', function() {
var dir = this.args[0];
if (dir) { grunt.config('dist', dir); }
});
grunt.registerTask('test', 'run tests on single-run server', function() {
var options = ['--single-run', '--no-auto-watch', '--log-level=warn'];
if (process.env.TRAVIS) {
options = options.concat(['--browsers=Firefox']);
} else {
//Can augment options with command line arguments
options = options.concat(this.args);
}
runTestacular('start', options);
});
grunt.registerTask('server', 'start testacular server', function() {
var options = ['--no-single-run', '--no-auto-watch'].concat(this.args);
runTestacular('start', options);
});
grunt.registerTask('test-run', 'run tests against continuous testacular server', function() {
var options = ['--single-run', '--no-auto-watch'].concat(this.args);
runTestacular('run', options);
});
grunt.registerTask('test-watch', 'start testacular server, watch & execute tests', function() {
var options = ['--no-single-run', '--auto-watch'].concat(this.args);
runTestacular('start', options);
});
function runTestacular(command, options) {
var testacularCmd = process.platform === 'win32' ? 'testacular.cmd' : 'testacular';
var args = [command, 'test/test-config.js'].concat(options);
var done = grunt.task.current.async();
var child = grunt.utils.spawn({
cmd: testacularCmd,
args: args
}, function(err, result, code) {
if (code) {
done(false);
} else {
done();
}
});
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
}
};