-
Notifications
You must be signed in to change notification settings - Fork 17
/
gulpfile.js
32 lines (27 loc) · 1.03 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
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const gxml = require('gulp-xml2js');
const rename = require('gulp-rename');
const projFileMatcher = /\.[fc]sproj$/;
const mockPath = 'test/mocks';
gulp.task('generate-json', (callback) => {
fs.readdir(mockPath, (err, files) => {
const numFiles = files.length;
let numFilesPiped = 0;
files.forEach((file) => {
if (projFileMatcher.test(file)) {
gulp.src(path.resolve(mockPath, file))
.pipe(gxml())
.pipe(rename((path) => path.extname = '.json'))
.pipe(gulp.dest(path.join('.', 'out', mockPath)))
.on('end', () => ++numFilesPiped !== numFiles || cb())
}
});
});
});
gulp.task('copy-mock-files', () => {
gulp.src(path.join(mockPath, 'mockProject', '**', '*'))
.pipe(gulp.dest(path.join('.', 'out', mockPath, 'mockProject')));
});
gulp.task('prepare-files', ['copy-mock-files', 'generate-json']);