-
Notifications
You must be signed in to change notification settings - Fork 1
/
gruntfile.js
124 lines (109 loc) · 3.21 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
116
117
118
119
120
121
122
123
124
'use strict';
module.exports = function (grunt) {
if (grunt.option('help')) {
require('load-grunt-tasks')(grunt);
} else {
require('jit-grunt')(grunt, {
force: 'grunt-force-task',
});
}
require('time-grunt')(grunt);
var concatConfig = {
dist: {
files: [{
src: [
'<%= config.files.src %>',
],
dest: 'dist/angular-token-auth.js',
}],
},
};
var uglifyConfig = {
dist: {
options: {
screwIE8: false,
},
files: {
'dist/angular-token-auth.min.js': 'dist/angular-token-auth.js',
},
},
};
var watchConfig = {
lint: {
files: ['<%= config.files.lint %>'],
tasks: ['lint'],
},
build: {
files: ['<%= config.files.src %>'],
tasks: ['build'],
},
};
grunt.initConfig({
config: {
lib: 'bower_components',
modules: 'src',
files: {
src: 'src/**/*.js',
lint: [
'<%= config.files.src %>',
'<%= config.files.karmaMocks %>',
'<%= config.files.karmaTests %>',
'./grunt/**/*.js',
'Gruntfile.js',
],
karmaMocks: 'tests/mocks/**/*.js',
karmaTests: 'tests/unit/**/*.js',
},
},
eslint: {
all: {
options: {
config: '.eslintrc',
},
src: '<%= config.files.lint %>',
},
},
concat: concatConfig,
uglify: uglifyConfig,
watch: watchConfig,
});
// Load external grunt task config.
grunt.loadTasks('./grunt');
grunt.registerTask('default', [
'test',
]);
grunt.registerTask('build', 'Concat and uglify', [
'concat',
'uglify',
]);
grunt.registerTask('lint', 'Run the JS linters.', [
'eslint',
]);
grunt.registerTask('test', 'Run the tests.', function (env) {
var karmaTarget = 'dev';
if (grunt.option('debug')) {
karmaTarget = 'debug';
}
if (env === 'ci' || env === 'travis') {
karmaTarget = 'ci';
}
grunt.task.run([
'force:lint',
'force:karma:' + karmaTarget,
'errorcodes',
]);
});
grunt.registerTask('travis', 'Run the tests in Travis', [
'test:travis',
]);
// This is used in combination with grunt-force-task to make the most of a
// Travis build, so all tasks can run but the build will fail if any of the
// tasks failed/errored.
grunt.registerTask('errorcodes', 'Fatally error if any errors or warnings have occurred but Grunt has been forced to continue', function () {
grunt.log.writeln('errorcount: ' + grunt.fail.errorcount);
grunt.log.writeln('warncount: ' + grunt.fail.warncount);
if (grunt.fail.warncount > 0 || grunt.fail.errorcount > 0) {
grunt.fatal('Errors have occurred.');
}
});
};