forked from C2FO/patio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
101 lines (94 loc) · 3.67 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
/*global module:false*/
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
src: ["./index.js", "lib/**/*.js", "Gruntfile.js"],
options: {
jshintrc: '.jshintrc'
}
},
exec: {
runMySqlCov: "export NODE_PATH=lib-cov:$NODE_PATH && export NODE_ENV=test-coverage && export PATIO_DB=mysql && ./node_modules/it/bin/it -r dotmatrix --cov-html ./docs-md/coverage.html",
runPsqlCov: "export NODE_PATH=lib-cov:$NODE_PATH && export NODE_ENV=test-coverage && export PATIO_DB=pg && ./node_modules/it/bin/it -r dotmatrix --cov-html ./docs-md/coverage.html",
installCoverage: "cd support/jscoverage && ./configure && make && mv jscoverage node-jscoverage",
createCoverage: "rm -rf ./lib-cov && node-jscoverage ./lib ./lib-cov",
removeDocs: "rm -rf docs/*",
createDocs: 'coddoc -f multi-html -d ./lib --dir ./docs'
},
it: {
all: {
src: 'test/**/*.test.js',
options: {
timeout: 3000, // not fully supported yet
reporter: 'tap'
}
}
}
});
grunt.registerTask('test_mysql', 'set PATIO_DB to mysql', function () {
var done = this.async();
var env = process.env;
env.NODE_PATH = "./lib";
env.PATIO_DB = "mysql";
grunt.util.spawn({cmd: "grunt", args: ["it"], opts: {stdio: 'inherit', env: env}}, function (err) {
if (err) {
done(false);
} else {
done();
}
});
});
grunt.registerTask('test_psql', 'set PATIO_DB to pg', function () {
var done = this.async();
var env = process.env;
env.NODE_PATH = "./lib";
env.PATIO_DB = "pg";
grunt.util.spawn({cmd: "grunt", args: ["it"], opts: {stdio: 'inherit', env: env}}, function (err) {
if (err) {
done(false);
} else {
done();
}
});
});
grunt.registerTask('test_psql_cov', 'set PATIO_DB to pg', function () {
var done = this.async();
var env = process.env;
env.NODE_PATH = "./lib-cov";
env.NODE_ENV = "test-coverage";
env.PATIO_DB = "pg";
grunt.util.spawn({cmd: "grunt", args: ["it"], opts: {stdio: 'inherit', env: env}}, function (err) {
if (err) {
done(false);
} else {
done();
}
});
});
grunt.registerTask('test_mysql_cov', 'set PATIO_DB to pg', function () {
var done = this.async();
var env = process.env;
env.NODE_PATH = "./lib-cov";
env.NODE_ENV = "test-coverage";
env.PATIO_DB = "mysql";
grunt.util.spawn({cmd: "grunt", args: ["it"], opts: {stdio: 'inherit', env: env}}, function (err) {
if (err) {
done(false);
} else {
done();
}
});
});
// Default task.
grunt.registerTask('default', ['jshint', "test", "test-coverage", "docs"]);
grunt.registerTask("test-coverage", ["exec:createCoverage", "exec:runMySqlCov", "exec:runPsqlCov"]);
grunt.registerTask("docs", ["exec:removeDocs", "exec:createDocs"]);
grunt.loadNpmTasks('grunt-it');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('mysql', ['jshint', 'mysql_env', 'it']);
grunt.registerTask('pg', ['jshint', 'test_psql']);
grunt.registerTask('test', ['jshint', 'test_mysql', 'test_psql']);
grunt.loadNpmTasks('grunt-exec');
};