This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathGruntfile.js
63 lines (52 loc) · 1.49 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
/*global module:false*/
var child_process = require('child_process');
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
watch: {
files: [ 'www/templates/*.tmpl' ],
tasks: 'fixtures mocha'
},
jshint: {
all: ['lib/**/*.js', 'test/tests/**/*.js', 'www/js/**/*.js'],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true,
globals: {
define: true,
require: true,
sinon: true
}
}
},
uglify: {},
mocha: {
index: [ 'test/runner/index.html' ]
}
});
grunt.registerTask('fixtures', 'Build template fixture', function() {
var obj = {};
var addFile = function(filepath, contents) {
obj[ filepath.replace('templates/', '') ] = contents;
};
var options = {cwd: 'www'};
grunt.file.expand(options, 'templates/*.tmpl').forEach(function(filepath) {
addFile(filepath, grunt.file.read('www/' + filepath));
});
var src = 'define(function() { return ' + JSON.stringify(obj, null, 2) + '; });';
grunt.file.write('test/fixtures/templates.js', src);
});
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['jshint', 'mocha']);
grunt.registerTask('test', ['fixtures', 'mocha', 'jshint']);
};