-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgruntfile.js
More file actions
130 lines (121 loc) · 2.9 KB
/
gruntfile.js
File metadata and controls
130 lines (121 loc) · 2.9 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
/* global module, require */
'use strict';
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('load-grunt-tasks')(grunt);
// configurable paths
var paths = {
app: 'app', // points to main source directory
test: 'test', // points to test source directory
tmp: 'tmp' // points to tmp directory that keeps logs and build reports
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// chekstyle for js
jshint: {
options: {
jshintrc: '.jshintrc', // file with checkstyle rules
reporter: require('jshint-stylish') // nicer output for jshint
},
all: [paths.app + '/**/*.js']
},
// test js code
mochaTest: {
unit: {
options: {
reporter: 'spec',
require: paths.test + '/blanket'
},
src: [paths.test + '/unit/**/*.js']
},
integration: {
options: {
reporter: 'spec',
require: paths.test + '/blanket'
},
src: [paths.test + '/integration/**/*.js']
},
coverage: {
options: {
reporter: 'html-cov',
quiet: true,
captureFile: paths.tmp + '/coverage.html'
},
src: [paths.test + '/**/*.js']
}
},
// watch changes in js files and validate them
watch: {
js: {
files: [
paths.app + '/**/*.js',
paths.test + '/**/*.js'
],
tasks: ['jshint', 'mochaTest:unit']
}
},
// monitos changes in application and restart the server
nodemon: {
dev: {
script: paths.app + '/start.js',
options: {
ignore: ["bin/**", "test/**", "node_modules/**", "resport/**"],
nodeArgs: ["--debug"],
delayTime: 1,
watch: [paths.app, 'gruntfile.js'],
ext: "js"
}
}
},
// remove temporary directories
clean: {
tmp: [paths.tmp + '/**'],
},
// debugging mechanism
"node-inspector": {
dev: {
options: {
'web-port': 1337,
'debug-port': 5858
}
}
},
// starts nodemon with node-inspector
concurrent: {
dev: {
tasks: ["nodemon", "node-inspector"],
options: {
logConcurrentOutput: true
}
}
}
});
// Log updated files from 'watch' events
grunt.event.on('watch', function(action, filepath, target) {
grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
});
// Reporting
grunt.registerTask('report', [
'jshint', // check code quality
'mochaTest:coverage' // check test coverage
]);
// Testing
grunt.registerTask('test', [
'mochaTest:unit', // run unit tests
'mochaTest:integration' // run unit tests
]);
// Default task
grunt.registerTask('default', [
'clean', // cleans temporary directory
'test', // run tests
'report' // generate reports
]);
// Development
// grunt watch // watch for changes in js files in order to run tests
// grunt dev // start nodejs and reloads on changes, start debugger on default port 1337
grunt.registerTask('dev', [
'concurrent:dev'
]);
};