-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
64 lines (54 loc) · 1.74 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
(() => {
'use strict';
const concat = require('gulp-concat');
const del = require('del');
const gulp = require('gulp');
const jshint = require('gulp-jshint');
const replace = require('gulp-replace');
const rollup = require('rollup').rollup;
const shell = require('gulp-shell');
const stylish = require('jshint-stylish');
const ISTANBUL_COMMAND = './node_modules/istanbul/lib/cli.js' +
' cover ./node_modules/mocha/bin/_mocha -- -R spec test/*Spec.js';
gulp.task('build', ['concat-bundle']);
gulp.task('bundle', () => {
return rollup({
entry: 'src/asmjs/main.js'
}).then(bundle => {
return bundle.write({
format: 'es6',
moduleId: 'test-asm',
moduleName: 'testAsm',
dest: './tmp/main-rollupped.js'
});
});
});
gulp.task('clean', callback => {
del(['coverage'], callback);
});
gulp.task('concat-bundle', ['reformat-bundle'], () => {
return gulp.src([
'./src/asmjs/pre.txt',
'./tmp/main-replaced.js',
'./src/asmjs/post.txt'
])
.pipe(concat('main.js'))
.pipe(gulp.dest('./'));
});
gulp.task('istanbul', ['build', 'jshint'], shell.task([ISTANBUL_COMMAND]));
gulp.task('jshint', () => {
return gulp.src('src/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('reformat-bundle', ['bundle'], (cb) => {
return gulp.src('./tmp/main-rollupped.js')
.pipe(replace('var EXPORTS = ', 'return '))
.pipe(replace('export { EXPORTS };', ''))
.pipe(replace('_CMP_FUNCTION_TABLE', 'CMP_FUNCTION_TABLE'))
.pipe(concat('main-replaced.js'))
.pipe(gulp.dest('./tmp'));
});
gulp.task('test', ['istanbul']);
})();