-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
78 lines (69 loc) · 2.34 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const gulp = require( 'gulp' ),
babel = require( 'gulp-babel' ),
benchmark = require( 'gulp-bench' ),
gutil = require( 'gulp-util' ),
istanbul = require( 'gulp-istanbul' ),
jsdoc = require( 'gulp-jsdoc-to-markdown' ),
mocha = require( 'gulp-mocha' ),
rename = require( 'gulp-rename' ),
sourcemaps = require( 'gulp-sourcemaps' ),
mergeStream = require( 'merge-stream' ),
colors = gutil.colors,
log = gutil.log;
gulp.task( 'dist', [ 'docs' ], () => mergeStream(
// Distribution for modern environments
gulp.src( [ 'src/emitter.js' ] )
.pipe( sourcemaps.init() )
.pipe( sourcemaps.write() )
.pipe( gulp.dest( 'dist' ) ),
// Distribution for legacy environments
gulp.src( [ 'src/emitter.js' ] )
.pipe( sourcemaps.init() )
.pipe( babel( {
plugins: [ '@babel/transform-modules-umd' ],
presets: [ '@babel/env' ]
} ) )
//.pipe( uglify() )
.pipe( rename( 'emitter-umd.js' ) )
.pipe( sourcemaps.write() )
.pipe( gulp.dest( 'dist' ) )
)
);
gulp.task( 'docs', () => {
return gulp.src( [ 'src/emitter.js' ] )
.pipe( jsdoc() )
.on( 'error', ( error ) => {
log( colors.red( 'jsdoc failed' ), error.message );
} )
.pipe( rename( {
basename: 'API',
extname: '.md'
} ) )
.pipe( gulp.dest( 'docs' ) );
} );
gulp.task( 'test', [ 'dist' ], ( done ) => {
gulp.src( [ 'dist/emitter-umd.js' ] )
/*.pipe( sourcemaps.init() )
.pipe( babel( {
plugins: [ 'transform-es2015-modules-umd' ],
presets: [ 'es2015' ]
} ) )
.pipe( sourcemaps.write() )*/
.pipe( istanbul( {
//instrumenter: Instrumenter
} ) )
.pipe( istanbul.hookRequire() )
.on( 'finish', () => {
gulp.src( [ 'test/test.js' ], { read: false } )
.pipe( mocha() )
.pipe( istanbul.writeReports() )
.on( 'end', done );
} );
} );
gulp.task( 'benchmark', [ 'dist' ], () => {
return gulp.src( [ 'test/benchmark.js' ] )
.pipe( benchmark() )
.pipe( gulp.dest( './benchmark' ) );
} );
gulp.task( 'default', [ 'test' ] );