This repository was archived by the owner on Apr 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGruntfile.js
More file actions
132 lines (120 loc) · 3.84 KB
/
Copy pathGruntfile.js
File metadata and controls
132 lines (120 loc) · 3.84 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
/*
Copyright (c) 2015, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License.
See the accompanying LICENSE file for terms.
*/
module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json');
grunt.initConfig({
pkg: pkg,
jshint: {
files: ['src/*.js'],
options: {
scripturl: true,
camelcase: true,
unused: true
}
},
bower: {
forTests: {
options: {
targetDir: 'tests/bower_components',
cleanup: true
}
}
},
uglify: {
options: {
banner: '/**\n'
+ ' * <%= pkg.name %> - v<%= pkg.version %>\n'
+ ' * Yahoo! Inc. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.\n'
+ ' */\n'
},
build: {
files: (function() {
// extract source code of privFilters from xssFilters
var privFiltersSrc = require('xss-filters')._getPrivFilters.toString();
grunt.file.write('dist/' + pkg.name + '.js',
'(function(){var privFilters = ' + privFiltersSrc + '();'
+ grunt.file.read('src/' + pkg.name + '.js')
+'})()');
return {
'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.js',
'dist/<%= pkg.name %>.min.<%= pkg.version %>.js': 'dist/<%= pkg.name %>.min.js'
}
})()
}
},
karma: {
options: {
configFile: 'karma.conf.js'
},
integrateHB1: {
options: {
files: [
'tests/bower_components/expect/index.js',
'tests/bower_components/handlebars-1.3/handlebars.js',
'dist/<%= pkg.name %>.min.js',
'tests/integration/spec/*.js'
],
junitReporter: {
outputFile: './artifacts/test/node-test-results(hbv1).xml'
}
}
},
integrateHB2: {
options: {
files: [
'tests/bower_components/expect/index.js',
'tests/bower_components/handlebars-2.0/handlebars.js',
'dist/<%= pkg.name %>.min.js',
'tests/integration/spec/*.js'
],
junitReporter: {
outputFile: './artifacts/test/node-test-results(hbv2).xml'
}
}
},
integrateHB3: {
options: {
files: [
'tests/bower_components/expect/index.js',
'tests/bower_components/handlebars-3.0/handlebars.js',
'dist/<%= pkg.name %>.min.js',
'tests/integration/spec/*.js'
],
reporters: ['coverage', 'junit', 'progress'],
// Test coverage
preprocessors: {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
'dist/secure-handlebars-helpers.min.js': 'coverage'
},
// optionally, configure the reporter
coverageReporter: {
reporters: [
{ type: 'lcov', dir: './artifacts/', subdir: 'coverage' },
{ type: 'json', dir: './artifacts/', subdir: 'coverage' }
//{ type: 'text' }
]
},
junitReporter: {
outputFile: './artifacts/test/node-test-results.xml'
}
}
}
},
clean: {
all: ['artifacts', 'coverage', 'node_modules', 'tests/bower_components']
}
});
grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('build', ['uglify']);
grunt.registerTask('test', ['jshint', 'bower:forTests', 'karma']);
grunt.registerTask('default', ['build', 'test']);
};