-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
59 lines (53 loc) · 1.44 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
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var stylish = require('jshint-stylish');
var fs = require('fs');
function write(filename, data) {
return new Promise(function(resolve, reject) {
fs.writeFile(filename, data, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
gulp.task('default', function() {
});
gulp.task('lint', function() {
return gulp
.src(['./*.js', './lib/*.js', './bin/*.js', './tests/*.js'])
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('tests', function() {
return gulp
.src('tests/*.tests.js', { read: false })
.pipe(mocha());
});
gulp.task('example', function() {
var doc = require('./lib/ramldoc').create({
template: 'templates/plain/main.hbs'
});
var promise = doc.parseFile('examples/jukebox-api/jukebox-api.raml');
return Promise
.all([
promise.then(function(obj) {
return write('examples/jukebox-api/jukebox-api.json', JSON.stringify(obj, false, ' '));
}),
promise.then(function(obj) {
return doc.render(obj).then(function(text) {
return write('examples/jukebox-api/jukebox-api.html', text);
});
})
])
.catch(function(ex) {
console.error(ex);
throw ex;
});
});
gulp.task('example-watch', function() {
return gulp.watch(['templates/*', 'examples/jukebox-api/*'], ['example']);
});