-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
115 lines (108 loc) · 3.19 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
module.exports = function(grunt) {
grunt.initConfig({
// removes files from the dist (built files) folder
clean: ['dist'],
// compiles ts code into js
ts: {
base: {
src: ['app/**/*.ts', 'spec/*.ts'],
dest: 'dist',
options: {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}
},
// lints ts code for errors
tslint: {
options: {
// can be a configuration object or a filepath to tslint.json
configuration: "tslint.json",
// If set to true, tslint errors will be reported, but not fail the task
// If set to false, tslint errors will be reported, and the task will fail
force: false
},
files: {
src: ['app/**/*.ts']
}
},
// copies static asset files to the dist (built files) folder
copy: {
css: {
expand: true,
cwd:'app',
src: ['**/*.css'],
dest: 'dist/',
},
html: {
expand: true,
cwd:'app',
src: ['**/*.html'],
dest: 'dist/',
}
},
// concurrently runs grunt tasks more info at https://github.com/sindresorhus/grunt-concurrent
concurrent: {
dev: {
tasks: ['nodemon', 'mochaTest', 'karma', 'watch'],
options: {
logConcurrentOutput: true
}
}
},
nodemon: {
dev: {
script: 'server/app.js'
}
},
// watch ts files and static asset files for changes and re-builds
watch: {
ts: {
files: ['app/**/*.ts', 'spec/*.ts'],
tasks: ['ts']
},
copy: {
files: ['app/**/*.css', 'app/**/*.html'],
tasks: ['copy:css', 'copy:html']
}
},
// run front end unit tests with karma
karma: {
unit: {
configFile: 'karma.conf.js',
autoWatch: true
}
},
// run back end unit tests with mocha
mochaTest: {
test: {
options: {
reporter: 'spec',
captureFile: 'results.txt', // Optionally capture the reporter output to a file
quiet: false, // Optionally suppress output to standard out (defaults to false)
clearRequireCache: false, // Optionally clear the require cache before running tests (defaults to false)
noFail: false // Optionally set to not fail on failed tests (will still fail on other errors)
},
src: ['server/test/*.js']
}
},
});
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks("grunt-tslint");
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.registerTask('build', ['clean', 'tslint', 'ts','copy:css', 'copy:html']);
grunt.registerTask('default', ['build', 'concurrent']);
grunt.registerTask('deploy', ['clean', 'ts', 'copy:css', 'copy:html']);
};