-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
85 lines (74 loc) · 2.49 KB
/
gulpfile.babel.js
File metadata and controls
85 lines (74 loc) · 2.49 KB
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
79
80
81
82
83
84
85
import gulp from 'gulp';
import path from 'path';
import del from 'del';
import runSequence from 'run-sequence';
import babelCompiler from 'babel-core/register';
import gulpLoadPlugins from 'gulp-load-plugins';
const plugins = gulpLoadPlugins();
const paths = {
js: ['./**/*.js', '!dist/**', '!node_modules/**', '!test/**', '!coverage/**', '!log/**'],
files: ['./package.json', './.gitignore'],
tests: {
integration: './test/integration/**/*.js',
unit: './test/unit/**/*.js'
},
build: 'dist'
};
const opt = {
dir: './coverage',
reporters: [ 'lcov', 'json', 'text', 'text-summary', 'clover'],
reportOpts: { dir: './coverage' },
};
gulp.task('help', plugins.taskListing);
gulp.task('clean', () => del(['dist/**', '!dist']));
gulp.task('copy', () =>
gulp.src(paths.files)
.pipe(plugins.newer(paths.build))
.pipe(gulp.dest(paths.build))
);
gulp.task('babel', () =>
gulp.src([...paths.js, '!gulpfile.babel.js'], { base: '.' })
.pipe(plugins.newer(paths.build))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.babel())
.pipe(plugins.sourcemaps.write('.', {
includeContent: false,
sourceRoot(file) {
return path.relative(file.path, __dirname)
}
}))
.pipe(gulp.dest(paths.build))
);
gulp.task('nodemon', ['copy', 'babel'], () =>
plugins.nodemon({
script: path.join(paths.build, 'index.js'),
ignore: ['node_modules/**/*.js', 'dist/**/*.js'],
tasks: ['copy', 'babel']
})
.on('restart', () => console.log('>> node restart'))
);
gulp.task('test', () =>
gulp.src(['dist/app/**.*js'])
.pipe(plugins.plumber())
.pipe(plugins.istanbul())
.pipe(plugins.istanbul.hookRequire())
.on('finish', () =>
gulp.src('./test/**/*.js')
.pipe(plugins.mocha({
reporter: 'spec',
ui: 'bdd',
recursive: true,
compilers: {
js: babelCompiler
}
}))
.pipe(plugins.istanbul.writeReports(opt))
.pipe(plugins.istanbul.enforceThresholds({ thresholds: { global: 10 } }))
.on('end', () => console.log('>>Finished Running Tests'))
.pipe(plugins.exit())
)
);
gulp.task('serve', ['clean'], () => runSequence('nodemon'));
gulp.task('default', ['clean'], () => {
runSequence(['copy', 'babel']);
});