-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
43 lines (42 loc) · 1.24 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
const { src, dest, task, series, watch } = require('gulp');
const rename = require('gulp-rename');
const through = require('through2');
const Vinyl = require('vinyl');
const chalk = require('chalk');
const debug = require('gulp-debug');
const changed = require('gulp-changed');
const demoPath = 'ng-hertz-doc/src/app/components/*/demo/*.ts';
const markPath = 'ng-hertz-doc/src/assets/markdown/components';
const handleFile = function () {
return through.obj(function (file, encoding, callback) {
const vinyl = new Vinyl(file);
const newContent = '```angular\n' + vinyl.contents.toString() + '\n```';
vinyl.contents = new Buffer.from(newContent);
return callback(null, vinyl);
});
};
task('mark', function () {
return src(demoPath)
.pipe(
rename(function (path) {
path.dirname = path.dirname.replace('/demo', '');
path.extname = '.md';
})
)
.pipe(changed(markPath))
.pipe(handleFile())
.pipe(
debug({
title: '🚚 mark:',
showCount: false,
logger: message => {
console.log(chalk.cyan(message));
}
})
)
.pipe(dest(markPath));
});
task('watch', function () {
watch(demoPath, series('mark'));
});
task('start', series('mark', 'watch'));