-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
44 lines (35 loc) · 1.24 KB
/
gulpfile.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
const gulp = require('gulp');
const {spawn} = require('child-process-promise');
const webdriver = require('gulp-webdriver');
const runSequence = require('run-sequence');
const util = require('gulp-util');
const environment = util.env.environment || 'local';
gulp.task('server:start', function (callback) {
dockerCompose(['up', '-d'], callback);
});
gulp.task('pipeline', function(callback) {
runSequence('server:start', 'test:e2e', 'server:stop', callback)
});
gulp.task('test:e2e', function () {
return gulp.src(`config/${environment}.conf.js`).pipe(webdriver());
});
gulp.task('server:stop', function (callback) {
dockerCompose(['down'], callback)
});
function dockerCompose(args, callback){
const promise = spawn('docker-compose', args);
const childProcess = promise.childProcess;
console.log('[spawn] childProcess.pid: ', childProcess.pid);
childProcess.stdout.on('data', function (data) {
console.log('[spawn] stdout: ', data.toString());
});
childProcess.stderr.on('data', function (data) {
console.log('[spawn] stderr: ', data.toString());
});
promise
.then(() => callback())
.catch((error) => {
console.log(error);
process.exit(1);
})
}