-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.js
48 lines (38 loc) · 1.21 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
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var writ = require('gulp-writ');
var rename = require('gulp-rename2');
var del = require('del');
var path = require('path');
var config = {};
config.dir = {
tutorials: './docs/tutorials',
examples: './examples',
};
config.files = {
tutorials: path.join(config.dir.tutorials, '*.md'),
examples: path.join(config.dir.examples, '*.py'),
deps: './node_modules/**/*',
};
gulp.task('clean', function(callback) {
return del([ config.files.examples ], { force: true }, callback);
});
gulp.task('generate-examples', [ 'clean' ], function() {
return gulp.src(config.files.tutorials)
.pipe(writ().on('error', gutil.log))
.pipe(rename(function(pathObj, filePath) {
var basename = pathObj.basename(filePath).replace(/^[0-9]+_/, '');
return pathObj.dirname(filePath) +'/'+ basename;
}))
.pipe(gulp.dest(config.dir.examples))
;
});
gulp.task('integration', [ 'generate-examples' ], function() {
// run generated integration test
});
gulp.task('default', [ 'integration' ]);
gulp.task('watch', [ 'default' ], function() {
gulp.watch(config.files.tutorials, [ 'integration' ]);
gulp.watch(config.files.deps, [ 'dist' ]);
});