-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
107 lines (89 loc) · 2.64 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
100
101
102
103
104
105
106
107
'use strict';
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
bump = require('gulp-bump'),
tag = require('gulp-tag-version'),
logger = require('./lib/services/logger'),
config = require('./lib/config'),
pm2 = require('pm2'),
runSequence = require('run-sequence');
var paths = {
scripts: ['lib/**/*.js', 'index.js'],
packages: [
'package.json'
]
};
gulp.task('test', function (done) {
});
gulp.task('patch', function() {
return gulp.src(paths.packages)
.pipe(bump({type: 'patch'}))
.pipe(gulp.dest('./'));
});
gulp.task('minor', function() {
return gulp.src(paths.packages)
.pipe(bump({type: 'minor'}))
.pipe(gulp.dest('./'));
});
gulp.task('major', function() {
return gulp.src(paths.packages)
.pipe(bump({type: 'major'}))
.pipe(gulp.dest('./'));
});
gulp.task('tag', function() {
return gulp.src(paths.packages[0])
.pipe(tag());
});
gulp.task('release', function() {
runSequence('lint', 'test');
});
gulp.task('release-patch', function() {
runSequence('lint', 'test', 'patch', 'tag');
});
gulp.task('release-minor', function() {
runSequence('lint', 'test', 'minor', 'tag');
});
gulp.task('release-major', function() {
runSequence('lint', 'test','major', 'tag');
});
gulp.task('lint', function() {
return gulp.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('pm2', function() {
pm2.connect(function() {
pm2.restart('Unityserver', function(err, instance) {
if (!err && instance) {
pm2.disconnect();
return logger.info('Unityserver instance restarted');
}
pm2.stop('Unityserver', function() {
logger.info('Stopped all Unityserver Processes');
pm2.delete('Unityserver', function() {
logger.info('Deleted all Unityserver Processes');
// Start a new set of instances if none exist
pm2.start({
name: 'Unityserver',
script : './',
exec_mode : 'cluster',
instances : 1,
max_memory_restart : '100M',
port: config.port
}, function(err, apps) {
for (var process in apps) {
var app = apps[process];
logger.info('Server instance started: ' + process);
logger.info('id: %s, state: %s, name: %s', app.id, app.state, app.pm2_env.name);
}
pm2.disconnect();
});// End of Start
});// End of Delete
});// End of Stop
});// End of Reload
});// End of Connect
});
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['lint', 'pm2']);
});
gulp.task('default', ['pm2', 'watch', 'lint']);