-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
33 lines (29 loc) · 1.05 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
'use strict';
const Promise = require('bluebird'),
connect = require('connect'),
gulp = require('gulp'),
serveStatic = require('serve-static'),
jshint = require('gulp-jshint'),
open = require('gulp-open'),
config = require('./config.json');
gulp.task('swagger', () => {
return Promise.promisify(function (cb) {
var app = connect();
app.use(serveStatic('./node_modules/swagger-ui/dist', {'index': ['index.html']}));
app.listen(config.swagger.ui_port, cb);
})()
.then(function () {
let uri = `http://${config.api_server.host}:${config.swagger.ui_port}/?url=` +
encodeURIComponent(`http://${config.api_server.host}:${config.api_server.port}/api-docs`);
console.log('API docs accessible at', uri);
return gulp.src(__filename)
.pipe(open({uri: uri}));
});
});
gulp.task('lint', () => {
return gulp.src(['./**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('default', ['lint']);