-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgruntfile.js
More file actions
122 lines (106 loc) · 4.1 KB
/
gruntfile.js
File metadata and controls
122 lines (106 loc) · 4.1 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'), // Read in package variable from package.json
filename: 'isNullOrEmpty.<%= pkg.version %>', // Construct a filename from package vars
timestamp: new Date().toUTCString(), // Get a timestamp for banner comments
// Construct a banner containing package and build information
banner: '/*! <%= filename %>.js | <%= pkg.url %> | <%= pkg.license %>\n' +
'* <%= pkg.author %> | <%= pkg.contact %>\n' +
'* Built on <%= timestamp %> */\n',
s: 'src/', // The source directory
d: 'dist/', // The distributable directory, where built files will end up
t: 'test/', // The test directory, for unit test files/specs
/**
* Concatenation setup. Concatenated files are built to the path defined by the d variable
* Includes closure banner and footer. Keep these in if you want to wrap concatenated code in closures
*/
concat: {
options: {
banner: '<%= banner %>' +
'\n;(function() {\n\n"use strict";\n',
footer: '\n})();\n'
},
dist: {
src: ['<%=s%>**/*.js'], // Define specific files in dependency order if required
dest: '<%= d %><%= filename %>.js'
}
},
/**
* Uglification (minification) setup. Uglified files are built to the path defined by the d variable and get a .min suffix
*/
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
files: {
'<%= d %><%= filename %>.min.js': ['<%= concat.dist.dest %>'] // Each concatenated file will get an uglified version
}
}
},
/**
* Jasmine unit test setup. Includes Istanbul code coverage setup with Coveralls-friendly output
*/
jasmine: {
src: ['<%=s%>**/*.js'], // Define specific files in dependency order if required
options: {
specs: '<%=t%>**/*.js',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'coverage/coverage.json',
report: [
{ type: 'lcov', options: { dir: 'coverage' }}, // Create .lcov report, required by Coveralls
{ type: 'html', options: { dir: 'coverage/html' }}, // Create an html report, readable by humans
{ type: 'text-summary' } // Output results to console post-build
],
thresholds: {
// Test result thresholds all set to 0 to begin with. Commented values are suggestions
lines: 0, // 75
statements: 0, // 75
branches: 0, // 75
functions: 0 // 75
}
}
}
},
/**
* JSHint static analysis setup
*/
jshint: {
files: ['gruntfile.js', '<%=s%>**/*.js', '<%=t%>**/*.js'], // Analyse this file and all source and test files for errors
options: {
browser: true, // Assume general browser globals
globals: {
predef: [] // Any global variables go here, if required
}
}
},
/**
* Watch setup. The configured tasks will run when and of the files tested by JSHint are changed
*/
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint', 'jasmine']
},
/**
* Coveralls setup. Tells Coveralls where to find code coverage information
*/
coveralls: {
options: {
force: true
},
src: 'coverage/lcov.info'
}
});
// Load tasks in this order
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-coveralls');
// Register test and build tasks.These can be run from the command line with "grunt test" or "grunt build"
// "grunt watch" should be run while developing to notify you when things go wrong
grunt.registerTask('test', ['jshint', 'jasmine', 'coveralls']);
grunt.registerTask('build', ['jshint', 'jasmine', 'concat', 'uglify']);
};