forked from maasglobal/maas-tsp-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
45 lines (36 loc) · 1.15 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
const gulp = require('gulp');
const replace = require('gulp-replace');
const yaml = require('gulp-yaml');
const del = require('del');
const connect = require('gulp-connect');
const swaggerRoot = 'specs/maas-v1.json'
gulp.task('copy-swagger-ui', function() {
// Copies everything
return gulp.src(['node_modules/swagger-ui/dist/**/*', '!node_modules/swagger-ui/dist/index.html'])
.pipe(gulp.dest('docs'));
});
gulp.task('copy-specs', function() {
return gulp.src(['specs/**/*.json', 'specs/**/*.png', 'specs/**/*.svg'])
.pipe(gulp.dest('docs/specs'));
});
gulp.task('watch-specs', function() {
gulp.watch(['specs/**/*.yml'], ['transform-yaml', 'copy-specs']);
})
gulp.task('transform-yaml', function() {
return gulp.src('./specs/*.yml')
.pipe(yaml({ safe: true, space: 2 }))
.pipe(gulp.dest('./specs/'))
});
gulp.task('clean:docs', function () {
return del(['docs/**/*', '!docs/index.html']);
});
gulp.task('serve', function() {
return connect.server({
root: 'docs',
livereload: true
});
});
// Aliases
gulp.task('docs', ['copy-swagger-ui', 'copy-specs']);
gulp.task('build', ['transform-yaml']);
gulp.task('clean', ['clean:docs']);