This repository has been archived by the owner on Jun 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
67 lines (60 loc) · 2.05 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
/**
* This file is using javascript testing for a PHP transformation to prepare for a node.js future.
*/
/*jshint node:true*/
"use strict";
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
php: {
server: {
options: {
port: 8111
}
},
test: {
options: {
port: 8000
}
}
},
jasmine: {
test: {
src: 'src/js/**/*.js',
options: {
specs: 'test/spec/**/*.js',
helpers: ['test/util/**/*.js', 'test/lib/jquery-xpath/jquery.xpath.js'],
host: 'http://127.0.0.1:8000/',
keepRunner: true,
vendor: ['http://codeorigin.jquery.com/jquery-2.0.3.min.js']
}
}
},
prep: {
xforms: {
src: 'test/form/*.xml',
dest: 'test/util/xforms.util.js'
}
}
});
grunt.loadNpmTasks('grunt-php');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.registerMultiTask('prep', 'Preparing stuff', function() {
var dest, forms = [],
content = "// Dynamically created by grunt prep:xforms\r\n\r\nvar xforms = [\r\n\t\"";
this.files.forEach(function(xform) {
xform.src.filter(function(filePath) {
grunt.log.writeln('adding: ' + filePath);
forms.push(filePath);
//xformArrayStr += "\t\"" + filePath + "\",\r\n";
});
dest = xform.dest;
});
content += forms.join("\",\r\n\t\"") + "\"\r\n];\r\n";
grunt.file.write(dest, content);
grunt.log.writeln("created " + dest + " with " + forms.length + " XForms");
});
grunt.registerTask('server', ['php:server:keepalive']);
grunt.registerTask('test', ['prep:xforms', 'php:test', 'jasmine']);
grunt.registerTask('default', ['test']);
};