-
Notifications
You must be signed in to change notification settings - Fork 11
/
Gruntfile.js
70 lines (67 loc) · 2.02 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
module.exports = function (grunt) {
pkg = grunt.file.readJSON('package.json');
var distAll = "dist/"+ pkg.name + ".js";
var distMin = "dist/"+ pkg.name + "-min.js";
grunt.initConfig({
requirejs: {
hybrid: {
options: {
baseUrl: "./",
name: 'third_party/almond',
include: [
'src/main'
],
out: distAll,
optimize: 'none',
wrap: true
}
}
},
uglify : {
options: {
banner: '/*! <%= pkg.name %> v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> - http://clouda.com */\n'//添加banner
},
hybrid: {
files: [{
src: distAll,
dest: distMin
}]
}
},
mocha:{
test:{
src: ['test/autotest.html'],
}
},
autoTest:{
src: ['test/autotest/*.js']
}
});
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha');
grunt.registerMultiTask('autoTest','自动化测试脚本合并',function(){
var options = this.options();
var file = [];
this.files.forEach(function(filePair) {
//console.log(filePair);
filePair.src.forEach(function(src) {
file.push('\''+src.replace('test\/','')+'\'');
});
});
console.log(this);
var sc = 'require(['+file.join(',')+'],function(){mocha.run();});'
grunt.file.write('test/autotest.js', sc , {
encoding:"utf8"
});
});
grunt.registerTask('build', [
'requirejs:hybrid',
'uglify:hybrid'
]);
grunt.registerTask('test', [
'jshint',
'mocha'
]);
};