Skip to content

Commit 55e3ae6

Browse files
author
Cassio Terceiro
committed
Adapt example gulpfile to gulp 4
1 parent 288dfa6 commit 55e3ae6

1 file changed

Lines changed: 19 additions & 17 deletions

File tree

example/gulpfile.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,49 @@
11
'use strict';
22

33
// Required modules
4-
var gulp = require('gulp'),
5-
path = require('path'),
6-
_ = require('lodash'),
7-
doctoc = require('doctoc/lib/transform'),
8-
del = require('del'),
9-
$ = require('gulp-load-plugins')(),
10-
reactDocsPlugin = require('../');
4+
const gulp = require('gulp');
5+
const doctoc = require('doctoc/lib/transform');
6+
const del = require('del');
7+
const $ = require('gulp-load-plugins')();
8+
const reactDocsPlugin = require('../');
9+
const { exec } = require('child_process');
1110

1211
// Helper vars
1312
var docsDest = 'docs';
1413

1514
// Tasks
16-
gulp.task('default', ['react-docs']);
17-
18-
gulp.task('clean', function(cb) { del(docsDest, cb) });
15+
gulp.task('clean', function (cb) {
16+
del.sync(docsDest);
17+
cb();
18+
});
1919

20-
gulp.task('check:docs', ['docs'], function(cb) {
21-
exec('git diff --name-only docs/', function(err, diffFiles) {
20+
gulp.task('check:docs', function (cb) {
21+
exec('git diff --name-only docs/', function (err, diffFiles) {
2222
if (diffFiles.indexOf('.md') > -1) {
23-
$.util.log('Automatically generated documentation is not up to \
23+
console.log('Automatically generated documentation is not up to \
2424
date with the changes in the codebase. Please run `gulp` and commit the changes.');
2525
process.exit(1);
2626
} else {
27-
$.util.log('Automatically generated documentation is up to date!');
27+
console.log('Automatically generated documentation is up to date!');
2828
}
2929
cb();
3030
});
3131
});
3232

33-
gulp.task('react-docs', function() {
33+
gulp.task('react-docs', function () {
3434
var mdTitle = '# React Component Reference';
3535

3636
return gulp.src('./components/**/*.jsx')
3737
.pipe(reactDocsPlugin({
3838
path: docsDest
3939
}))
4040
.pipe($.concat('README.md'))
41-
.pipe($.tap(function(file) {
41+
.pipe($.tap(function (file) {
4242
// Generate table of contents for components.md
4343
var mdWithToc = doctoc(file.contents.toString(), null, 2, mdTitle).data;
44-
file.contents = new Buffer(mdWithToc);
44+
file.contents = Buffer.from(mdWithToc);
4545
}))
4646
.pipe(gulp.dest(docsDest));
4747
});
48+
49+
gulp.task('default', gulp.series('react-docs'));

0 commit comments

Comments
 (0)