forked from dynamoose/dynamoose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
93 lines (84 loc) · 2.35 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
'use strict';
var DynamoDbLocal = require('dynamodb-local');
var DYNAMO_DB_PORT = 8000;
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
app: {
src: ['gruntfile.js', 'index.js', 'lib/**/*.js'],
options: {
node: true,
jshintrc: '.jshintrc'
}
},
test: {
src: ['test/**/*.js' ],
options: {
node: true,
jshintrc: 'test/.jshintrc'
}
}
},
mochaTest: {
test: {
options: {
reporter: 'spec'
},
src: ['test/**/*.js']
},
testCoverage: {
options: {
reporter: 'spec',
require: 'test/coverage/blanket'
},
src: ['test/**/*.js']
},
coverage: {
options: {
reporter: 'html-cov',
// use the quiet flag to suppress the mocha console output
quiet: true,
// specify a destination file to capture the mocha
// output (the quiet option does not suppress this)
captureFile: 'coverage.html'
},
src: ['test/**/*.js']
},
'travis-cov': {
options: {
reporter: 'travis-cov'
},
src: ['test/**/*.js']
}
}
});
// Load libs
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.registerTask('dynamo:start', function() {
var getPID = 'ps aux | grep "DynamoDBLocal.jar -port ' +
DYNAMO_DB_PORT +
'" | grep -v grep | awk \'{print $2}\'';
var done = this.async();
require('child_process').exec(getPID, function (err, pid) {
if(err) {
return done(err);
}
if(pid) {
console.log('Killing DynamoDBLocal process');
process.kill(pid);
} else {
console.log('No DynamoDBLocal process running');
}
DynamoDbLocal
.launch(DYNAMO_DB_PORT)
.then(function() { done(); })
.catch(function(e) { done(e); });
});
});
// Register the default tasks
grunt.registerTask('default', ['jshint', 'dynamo:start', 'mochaTest']);
grunt.registerTask('test', ['jshint', 'dynamo:start', 'mochaTest:test']);
grunt.registerTask('coverage', ['jshint', 'dynamo:start', 'mochaTest:testCoverage', 'mochaTest:coverage', 'mochaTest:travis-cov']);
};