forked from OAI/OpenAPI-Specification
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
48 lines (39 loc) · 1.33 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
var gulp = require('gulp');
var jsonlint = require("gulp-jsonlint");
var gulpyaml = require('gulp-yaml');
var ext_replace = require('gulp-ext-replace');
var map = require('map-stream');
var YAML = require('json2yaml');
var gutil = require('gulp-util');
var exitCode = 0;
var json_paths = {
examples: 'examples/**/*.json',
models: 'fixtures/v2.0/json/models/**/*.json',
resources: 'fixtures/v2.0/json/resources/**/*.json',
responses: 'fixtures/v2.0/json/responses/**/*.json'
// What are the other files in fixtures/v2.0/json/*.json
};
gulp.task('lint', function() {
return gulp.src(['./**/*.json', '!./node_modules/**/*.json'])
.pipe(jsonlint())
.pipe(jsonlint.reporter());
// YAML linting/formatting?
});
gulp.task('yaml2json', function(){
gulp.src('./fixtures/v2.0/yaml/**.yaml')
.pipe(gulpyaml({ pretty: true }))
.pipe(gulp.dest('./fixtures/v2.0/json'));
gulp.src(json_paths.examples)
.pipe(gulpyaml({ pretty: true }))
.pipe(gulp.dest('examples/'));
});
gulp.task('json2yaml', function(){
return gulp.src('./fixtures/v2.0/json/**/*.json')
.pipe(map(function(file, cb) {
data = JSON.parse(file.contents);
file.contents = new Buffer(String(YAML.stringify(data)));
cb(null, file);
}))
.pipe(ext_replace('.yaml'))
.pipe(gulp.dest('fixtures/v2.0/yaml'));
});