-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
95 lines (86 loc) · 2.58 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
'use strict';
/* eslint-disable camelcase, no-sync */
const fs = require('fs');
module.exports = function(grunt) {
require('jit-grunt')(grunt, {
jsdoc2md: 'grunt-jsdoc-to-markdown',
})({
customTasksDir: 'tasks',
});
grunt.initConfig({
eslint: {
all: ['*.js', '@(lib|tasks|test)/**/*.js'],
},
env: {
main: {
NODE_ENV: 'development',
options: {
add: {
MYSQL_HOST: 'localhost',
MYSQL_PORT: 3306,
MYSQL_USER: 'root',
MYSQL_PASSWORD: '',
MYSQL_DATABASE: 'mysql_plus_test',
},
},
},
},
mochaTest: {
unit: {
src: 'test/unit/*.js',
},
integration: {
src: 'test/integration/*.js',
},
options: {
bail: grunt.option('bail'),
colors: true,
require: ['should', 'should-sinon'],
reporter: grunt.option('grep') ? 'spec' : 'dot',
},
},
mocha_istanbul: {
src: 'test/@(unit|integration)/*.js',
options: {
check: {
branches: 100,
lines: 100,
statements: 100,
},
mochaOptions: ['--colors', '--reporter', 'dot'],
require: ['should', 'should-sinon'],
reportFormats: [process.env.CI ? 'lcovonly' : 'html'],
},
},
jsdoc2md: {
docs: {
options: {
partial: [
'jsdoc2md/partials/body.hbs',
'jsdoc2md/partials/examples.hbs',
'jsdoc2md/partials/link.hbs',
'jsdoc2md/partials/linked-type-list.hbs',
'jsdoc2md/partials/main-index.hbs',
'jsdoc2md/partials/params-table.hbs',
'jsdoc2md/partials/param-table-name.hbs',
'jsdoc2md/partials/separator.hbs',
],
separators: true,
'sort-by': ['order'],
template: fs.readFileSync('jsdoc2md/README.hbs', 'utf8'),
},
src: ['lib/MySQLPlus.js', 'lib/PoolPlus.js', 'lib/Connection.js', 'lib/MySQLTable.js'],
dest: 'README.md',
},
},
});
// Register tasks
grunt.registerTask('lint', ['eslint']);
grunt.registerTask('testSetup', ['env', 'createTestDB']);
grunt.registerTask('test:unit', ['testSetup', 'mochaTest:unit']);
grunt.registerTask('test:integration', ['testSetup', 'mochaTest:integration']);
grunt.registerTask('test', ['testSetup', process.env.CI ? 'mocha_istanbul' : 'mochaTest']);
grunt.registerTask('coverage', ['env', 'createTestDB', 'mocha_istanbul']);
grunt.registerTask('doc', ['jsdoc2md', 'fixdocs']);
grunt.registerTask('default', ['lint', 'test']);
};