forked from Smartling/api-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (49 loc) · 1.46 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
var gulp = require('gulp');
var gulpConnect = require('gulp-connect');
var connect = require('connect');
var cors = require('cors');
var path = require('path');
var exec = require('child_process').exec;
var portfinder = require('portfinder');
var swaggerRepo = require('swagger-repo');
var log = require('fancy-log');
var colors = require('ansi-colors');
var DIST_DIR = 'web_deploy';
gulp.task('edit', function(done) {
portfinder.getPort({port: 5000}, function (err, port) {
var app = connect();
app.use(swaggerRepo.swaggerEditorMiddleware());
app.listen(port);
log(colors.green('swagger-editor started http://localhost:' + port));
});
done();
});
gulp.task('build', function (done) {
exec('npm run build', function (err, stdout, stderr) {
console.log(stderr);
done(err);
});
});
gulp.task('reload', gulp.series('build', function (done) {
gulp.src(DIST_DIR).pipe(gulpConnect.reload());
done();
}));
gulp.task('watch', function (done) {
gulp.watch(['spec/**/*', 'web/**/*'], gulp.series('reload'));
done();
});
gulp.task('serve', gulp.series('build', 'edit', 'watch', function() {
portfinder.getPort({port: 3000}, function (err, port) {
gulpConnect.server({
debug: true,
root: [DIST_DIR],
livereload: true,
port: port,
middleware: function (gulpConnect, opt) {
return [
cors()
]
}
});
});
}));