-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGruntfile.js
More file actions
182 lines (165 loc) · 3.91 KB
/
Gruntfile.js
File metadata and controls
182 lines (165 loc) · 3.91 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/**
* @file Grunt的task配置文件
* @author fzcs
* @copyright Dreamarts Corporation. All Rights Reserved.
*/
module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-contrib-less"); // 编译less,生成css文件
grunt.loadNpmTasks("grunt-contrib-watch"); // 监视文件变更,并执行指定的task
grunt.loadNpmTasks("grunt-contrib-jshint"); // 检查jshint
grunt.loadNpmTasks("grunt-contrib-clean"); // 清楚临时文件
grunt.loadNpmTasks("grunt-contrib-uglify"); // 压缩js文件
grunt.loadNpmTasks("grunt-contrib-copy"); // 复制文件
grunt.loadNpmTasks("grunt-jsdoc"); // 生成jsdoc文档
grunt.loadNpmTasks("grunt-mocha-cli"); // Node单元测试
grunt.loadNpmTasks("grunt-mocha-cov"); // 覆盖率
grunt.loadNpmTasks("grunt-jscoverage"); // 生成统计覆盖率用的文件
grunt.loadNpmTasks("grunt-plato"); // 分析代码复杂度,包括jshint等
grunt.initConfig({
/**
* less 编译器
*/
less: {
development: {
options: {
paths: []
},
files: {
"app/public/smartadmin/stylesheets/admin.css": "app/public/smartadmin/stylesheets/admin.less"
}
},
production: {
options: {
paths: []
, compress: true
},
files: {
"app/public/smartadmin/stylesheets/admin.min.css": "app/public/smartadmin/stylesheets/admin.less"
}
}
},
/**
* 监视文件变更(执行less编译)
*/
watch: {
less: {
files: ["*.less", "app/public/smartadmin/stylesheets/*.less"]
, tasks: ["less:development", "less:production"]
, options : {
livereload: true
, nospawn: true
}
}
},
/**
* 代码检查
*/
jshint: {
files: [
"lib/**/*.js"
, "app/admin/**/*.js"
, "bin/**/*.js"
, "test/cases/**/*.js"
]
, options: {
jshintrc: ".jshintrc"
}
},
/**
* 文档生成
*/
jsdoc : {
dist : {
src: [
"lib/**/*.js"
]
, options: {
destination: "docs"
}
}
},
/**
* Mocha单元测试
*/
mochacli: {
options: {
require: ["should"]
, reporter: "nyan"
, bail: true
},
all: [
"test/cases/core/*.js"
]
},
/**
* 生成coverage统计用代码
*/
jscoverage: {
options: {
inputDirectory: "lib",
outputDirectory: "test/coverage/lib"
}
},
/**
* 生成coverage报告
*/
mochacov: {
options: {
reporter: "html-cov"
, require: ["should"]
},
all: [
"test/cases/core/models/test_mod_company.js"
, "test/cases/core/models/test_mod_master.js"
]
},
/**
* 清除临时数据
*/
clean: [
"test/coverage"
, "docs"
],
/**
* 静态分析代码(结果生成到工程的reports目录下)
*/
plato: {
task: {
options : {
jshint : grunt.file.readJSON(".jshintrc")
},
files: {
"reports": ["lib/**/*.js"]
}
}
},
/**
* 压缩js文件
*/
uglify: {
target: {
files: {
"app/public/static/alertify.js": ["app/public/smart/alertify/alertify.js"],
"app/public/static/bootstrap.js": ["app/public/smart/bootstrap/js/bootstrap.js"]
}
}
},
/**
* 拷贝文件
*/
copy: {
main: {
files: [{
expand: true
, cwd: "app/public/"
, src: ["smart/**", "smartadmin/**"]
, dest: "app/public/static"
}]
}
}
});
grunt.registerTask("conv", ["jscoverage", "mochacov", "clean"]);
grunt.registerTask("test", ["mochacli"]);
grunt.registerTask("analyze", ["plato"]);
grunt.registerTask("compress", ["uglify"]);
};