|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | // 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'); |
11 | 10 |
|
12 | 11 | // Helper vars |
13 | 12 | var docsDest = 'docs'; |
14 | 13 |
|
15 | 14 | // 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 | +}); |
19 | 19 |
|
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) { |
22 | 22 | 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 \ |
24 | 24 | date with the changes in the codebase. Please run `gulp` and commit the changes.'); |
25 | 25 | process.exit(1); |
26 | 26 | } else { |
27 | | - $.util.log('Automatically generated documentation is up to date!'); |
| 27 | + console.log('Automatically generated documentation is up to date!'); |
28 | 28 | } |
29 | 29 | cb(); |
30 | 30 | }); |
31 | 31 | }); |
32 | 32 |
|
33 | | -gulp.task('react-docs', function() { |
| 33 | +gulp.task('react-docs', function () { |
34 | 34 | var mdTitle = '# React Component Reference'; |
35 | 35 |
|
36 | 36 | return gulp.src('./components/**/*.jsx') |
37 | 37 | .pipe(reactDocsPlugin({ |
38 | 38 | path: docsDest |
39 | 39 | })) |
40 | 40 | .pipe($.concat('README.md')) |
41 | | - .pipe($.tap(function(file) { |
| 41 | + .pipe($.tap(function (file) { |
42 | 42 | // Generate table of contents for components.md |
43 | 43 | var mdWithToc = doctoc(file.contents.toString(), null, 2, mdTitle).data; |
44 | | - file.contents = new Buffer(mdWithToc); |
| 44 | + file.contents = Buffer.from(mdWithToc); |
45 | 45 | })) |
46 | 46 | .pipe(gulp.dest(docsDest)); |
47 | 47 | }); |
| 48 | + |
| 49 | +gulp.task('default', gulp.series('react-docs')); |
0 commit comments