forked from dynamoose/dynamoose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
68 lines (61 loc) · 1.63 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
'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',
// 'esversion': 6
// }
// },
// test: {
// src: ['test/**/*.js' ],
// options: {
// node: true,
// jshintrc: 'test/.jshintrc',
// 'esversion': 6
// }
// }
// },
mochaTest: {
test: {
options: {
reporter: 'spec'
},
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', ['dynamo:start', 'mochaTest']);
grunt.registerTask('test', ['dynamo:start', 'mochaTest:test']);
};