-
Notifications
You must be signed in to change notification settings - Fork 15
/
Gruntfile.js
110 lines (101 loc) · 3.48 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
102
103
104
105
106
107
108
109
110
/*
* mockserver
* http://mock-server.com
*
* Copyright (c) 2014 James Bloom
* Licensed under the Apache License, Version 2.0
*/
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
exec: {
stop_existing_mockservers: './stop_MockServer.sh'
},
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.grunt_started %>',
'<%= nodeunit.grunt_stopped %>',
'<%= nodeunit.grunt_failure %>'
],
options: {
jshintrc: '.jshintrc'
}
},
start_mockserver: {
options: {
serverPort: 1080,
jvmOptions: [
'-Dmockserver.enableCORSForAllResponses=true',
'-Dmockserver.corsAllowMethods="CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, PATCH, TRACE"',
'-Dmockserver.corsAllowHeaders="Allow, Content-Encoding, Content-Length, Content-Type, ETag, Expires, Last-Modified, Location, Server, Vary, Authorization"',
'-Dmockserver.corsAllowCredentials=true -Dmockserver.corsMaxAgeInSeconds=300'
],
mockServerVersion: "5.15.0"
}
},
stop_mockserver: {
options: {
serverPort: 1080
}
},
nodeunit: {
grunt_started: [
'test/grunt/started/*_test.js'
],
grunt_stopped: [
'test/grunt/stopped/*_test.js'
],
grunt_failure: [
'test/grunt/failure/*_test.js'
],
node_started: [
'test/node/started/*_test.js'
],
node_stopped: [
'test/node/stopped/*_test.js'
],
node_failure: [
'test/node/failure/*_test.js'
],
options: {
reporter: 'nested'
}
}
});
grunt.registerTask('download_jar', 'Download latest MockServer jar version', function () {
var done = this.async();
var artifactoryHost = 'oss.sonatype.org';
var artifactoryPath = '/content/repositories/releases/org/mock-server/mockserver-netty/';
require('./downloadJar').downloadJar('5.15.0', artifactoryHost, artifactoryPath).then(function () {
done(true);
}, function () {
done(false);
});
});
grunt.registerTask('deleted_jars', 'Delete any old MockServer jars', function () {
var fs = require('fs');
var currentMockServerJars = require('glob').sync('**/mockserver-netty-*-jar-with-dependencies.jar');
currentMockServerJars.forEach(function (item) {
fs.unlinkSync(item);
console.log('Deleted ' + item);
});
currentMockServerJars.splice(0);
});
// load this plugin's task
grunt.loadTasks('tasks');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.registerTask('test', [
'start_mockserver:self',
'nodeunit:grunt_started',
'stop_mockserver:self',
'nodeunit:grunt_stopped',
'nodeunit:grunt_failure',
'nodeunit:node_failure',
'nodeunit:node_started'
]);
grunt.registerTask('default', ['exec:stop_existing_mockservers', 'deleted_jars', 'download_jar', 'jshint', 'test']);
};