This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
99 lines (90 loc) · 3.29 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
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
var gulp = require('gulp'),
run = require('gulp-run'),
browserSync = require('browser-sync').create(),
cleanCSS = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
usemin = require('gulp-usemin');
var jshint = require('gulp-jshint'),
git = require('gulp-git'),
gitignore = require('gulp-gitignore'),
runSequence = require('run-sequence'),
prompt = require('gulp-prompt'),
istanbul = require('gulp-istanbul'),
child_process = require('child_process'),
Server = require('karma').Server;
var exec = child_process.exec,
spawn = child_process.spawn;
var banner = ['/*!\n',
' * PITON - ES 2016.2\n',
' * Copyright 2016 - ' + (new Date()).getFullYear(), '\n',
' * Tema usado para base: Bootstrap Material Design\n',
' */\n',
''
].join('');
/**
* Task que realiza o push, antes executando os testes e
* o jshint e verificando se o código está ok.
*/
gulp.task('push', function (cb) {
var pushClient = spawn('gulp', ['--gulpfile', './client/gulpfile.js', 'test', '--color']);
pushClient.stdout.on('data', function (data) {
process.stdout.write(data.toString());
});
pushClient.stderr.on('data', function (data) {
process.stdout.write('stderr: ' + data.toString());
return sair(2)();
});
pushClient.on('exit', function (code) {
console.log('child process exited with code ' + code.toString());
if (code == 1) {
console.error('Os testes falharam. Conserte-os para poder dar push!');
return sair(1)();
} else {
console.log('Certifique-se que o serviço do mongo está rodando!');
console.log('(comando para ativar o serviço: sudo service mongodb start)');
var pushServer = spawn('gulp', ['--gulpfile', './server/gulpfile.js', 'push', '--color']);
pushServer.stdout.on('data', function (data) {
process.stdout.write(data.toString());
});
pushServer.stderr.on('data', function (data) {
process.stdout.write('stderr: ' + data.toString());
return sair(1)();
});
pushServer.on('exit', function (code) {
console.log();
console.log('child process exited with code ' + code.toString());
if (code == 1) {
console.error('Os testes falharam. Conserte-os para poder dar push!');
return sair(1)();
}
return sair(0)();
});
}
});
});
/**
* Task que adiciona as modificações para commit e realiza
* o commit.
*/
gulp.task('commit', function (cb) {
return gulp.src(['./*', '!node_modules/', '!coverage/'])
.pipe(gitignore())
.pipe(git.add())
.pipe(prompt.prompt({
type: 'input',
name: 'commit',
message: 'Insira a mensagem de commit...'
}, function (res) {
return gulp.src(['!node_modules/', '!coverage/', '!yarn.*', '!yarn-error.*', './*'], { buffer: false })
.pipe(git.commit(res.commit));
}));
});
/**
* Cria um callback que finaliza o processo com o status passado.
*/
function sair(status) {
return function () {
process.exit(status || 0);
};
}