forked from dynamoose/dynamoose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
66 lines (59 loc) · 1.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
'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']
}
}
});
// 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']);
};