forked from adrai/enum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
72 lines (61 loc) · 1.67 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
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var babel = require('gulp-babel');
var mocha = require('gulp-mocha');
var benchmark = require('gulp-bench');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var rimraf = require('gulp-rimraf');
var shell = require('gulp-shell');
var version = require('./package.json').version;
function compile() {
return gulp.src('lib/*.es6')
.pipe(babel({
experimental: true,
loose: ['es6.modules', 'es6.classes']
}))
.pipe(rename({
extname: '.js'
}));
}
gulp.task('es6-test', function() {
return compile()
.pipe(gulp.dest('lib'));
});
gulp.task('test', ['es6-test'], function() {
return gulp.src('test/enumTest.js')
.pipe(mocha())
.on('end', function () {
return gulp.src('lib/*.js')
.pipe(rimraf());
});
});
gulp.task('bench', ['es6-test'], function () {
return gulp.src('bench/*.js', {read: false})
.pipe(benchmark());
});
gulp.task('zuul', shell.task([
'$(npm bin)/zuul -- test/enumTest.js'
]));
gulp.task('test-ci', ['test', 'zuul']);
gulp.task('es6-build', function() {
return compile()
.pipe(gulp.dest('dist'));
});
gulp.task('build', ['es6-build'], function() {
return gulp.src('index.js')
.pipe(browserify({
standalone: 'Enum',
insertGlobals : true,
debug : !gulp.env.production
}))
.pipe(rename('enum-' + version + '.js'))
.pipe(gulp.dest('./'))
.on('finish', function () {
gulp.src('./enum-' + version + '.js')
.pipe(uglify())
.pipe(rename('enum-' + version + '.min.js'))
.pipe(gulp.dest('./'));
});
});
gulp.task('default', ['build']);