-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
110 lines (103 loc) · 2.44 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
module.exports = function(grunt) {
var path = require('path');
var exec = require('child_process').exec;
grunt.initConfig({
closurecompiler: {
compile: {
files: {
'./build/polyfill.min.js': ['./build/polyfill.js']
},
options: {
'compilation_level': 'ADVANCED_OPTIMIZATIONS',
'output_wrapper': '(function(){%output%}());'
}
}
},
'string-replace': {
cleanNewlines: {
files: {
'./build/polyfill.min.js': './build/polyfill.min.js'
},
options: {
replacements: [
{
pattern: /\n/gm,
replacement: ''
}
]
}
}
},
concat: {
polyfill: {
src: ['./src/polyfill.js'],
dest: './build/polyfill.js'
},
tests: {
src: [
'./src/tests/polyfill-module.js',
'./src/tests/polyfill/*.js'
],
dest: './tests/tests.js'
}
},
connect: {
root: {
options: {
port: 7357, // "TEST"
base: '.'
}
}
},
qunit: {
online: {
options: {
urls: [
'http://localhost:7357/tests/index.html'
]
}
},
offline: {
options: {
urls: [
'./tests/index.html'
]
}
}
},
karma: {
test: {
configFile: path.resolve(__dirname, 'karma.conf.js'),
singleRun: true
}
}
});
grunt.loadNpmTasks('grunt-closurecompiler');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-karma-0.9.1');
grunt.registerTask('build', ['concat:polyfill', 'concat:tests']);
grunt.registerTask('compile', ['closurecompiler:compile', 'string-replace:cleanNewlines']);
grunt.registerTask('onlineTest', ['connect:root', 'qunit:online']);
grunt.registerTask('offlineTest', ['qunit:offline']);
grunt.registerTask('realTest', ['karma:test']);
grunt.registerTask('test', ['realTest']);
// This is a bit ugly but I kinda just want it done with at the moment.
// The idea is that if we have a karma server running, use it, else use PhantomJS.
grunt.registerTask('quickTest', 'Run the appropriate quick test', function() {
var done = this.async();
exec('karma run', function(error, stdout, stderr) {
if (error) {
console.log('PhantomJS will be used.');
grunt.task.run('offlineTest');
}
else {
console.log('Karma test issued.');
}
done();
});
});
grunt.registerTask('default', ['build', 'compile', 'quickTest']);
};