1
- const del = require ( "del" ) ;
1
+ const { series , watch } = require ( 'gulp' ) ;
2
2
const gulp = require ( "gulp" ) ;
3
- const gulpSequence = require ( "gulp-sequence" ) ;
4
3
const exec = require ( "child_process" ) . exec ;
5
4
6
5
const execCmd = ( cmd , directory ) => {
@@ -30,27 +29,20 @@ const conf = {
30
29
}
31
30
} ;
32
31
33
- gulp . task ( "clean" , function ( ) {
34
- return del ( [ conf . output . dir ] ) ;
35
- } ) ;
32
+ async function prepareDemo ( cb ) {
33
+ await execCmd ( "yarn" , './src-demo' )
34
+ cb ( ) ;
35
+ }
36
36
37
- gulp . task ( "build" , function ( ) {
38
- return execCmd ( "yarn build" ) ;
39
- } ) ;
37
+ function copyToDemo ( ) {
38
+ return gulp . src ( conf . copyFrom , { base : "." } ) . pipe ( gulp . dest ( conf . copyTo ) )
39
+ }
40
40
41
- gulp . task ( "prepare-demo" , function ( ) {
42
- return execCmd ( "yarn" , './src-demo' ) ;
43
- } ) ;
44
-
45
- gulp . task ( "copy-to-demo" , function ( ) {
46
- return gulp . src ( conf . copyFrom , { base : "." } ) . pipe ( gulp . dest ( conf . copyTo ) ) ;
47
- } ) ;
48
-
49
- gulp . task ( "watch-and-copy-to-demo" , function ( ) {
50
- // Execute commands in series
41
+ function watchAndCopy ( cb ) {
42
+ // body omitted
51
43
execCmd ( "yarn watch" , '.' ) ;
52
- gulp . watch ( conf . output . dir , [ "copy-to-demo" ] ) ;
44
+ watch ( conf . output . dir , copyToDemo ) ;
53
45
execCmd ( "sleep 10 && yarn start" , 'src-demo' ) ;
54
- } ) ;
46
+ }
55
47
56
- gulp . task ( " start-demo" , gulpSequence ( "prepare-demo" , "watch-and-copy-to-demo" ) ) ;
48
+ exports [ ' start-demo' ] = series ( prepareDemo , watchAndCopy ) ;
0 commit comments