-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
93 lines (83 loc) · 2.46 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var webpack = require('gulp-webpack');
var del = require('del');
var browsersync = require('browser-sync');
var coveralls = require('gulp-coveralls');
var shell = require('gulp-shell');
var argv = require('yargs').argv;
var jsdoc = require('gulp-jsdoc3');
var insert = require('gulp-insert');
var version = argv.version ? argv.version : 'temp';
gulp.task('clean', function(){
return del('dist/**/*', { force: true });
});
gulp.task('eslint', function() {
return gulp.src('src/**/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('test:single', shell.task(['./node_modules/karma/bin/karma start karma.conf.js']));
gulp.task('test', ['test:single'], function(){
if(argv.watch){
browsersync({
port: 3000,
startPath: '/test/report/lcov-report',
server: {
baseDir: '.'
}
});
gulp.watch(['src/**/*.js', 'karma.conf.js', '!report/**/*.*'], ['test:single', browsersync.reload]);
}
});
gulp.task('coveralls', function(){
gulp.src('test/report/lcov.info')
.pipe(coveralls());
});
gulp.task('webpack', function(){
return gulp.src('src/main.js')
.pipe(webpack({
output: {
filename: 'main.js',
libraryTarget: 'umd',
library: 'facebookpixeladapter'
}
}))
.pipe(insert.append('\n\n/* facebookpixeladapter ' + version + ' */'))
.pipe(gulp.dest('dist/'));
});
gulp.task('doc:single', function(done){
gulp.src(['README.md', 'src/**/*.js'])
.pipe(jsdoc({
opts: {
destination: 'docs/' + version,
tags: {
allowUnknownTags: true
}
}
}, done));
});
gulp.task('doc', ['doc:single'], function(){
if(argv.watch){
browsersync({
port: 4000,
startPath: '/docs/' + version,
server: {
baseDir: '.'
}
});
gulp.watch(['README.md', 'src/**/*.js'], ['doc:single', browsersync.reload]);
}
});
gulp.task('build:single', ['eslint', 'test:single', 'doc:single', 'clean', 'webpack']);
gulp.task('build', ['build:single'], function(){
if(argv.watch){
browsersync({
port: 5000,
startPath: '/examples/',
server: {}
});
gulp.watch(['examples/**/*.js', 'src/**/*.js'], ['build:single', browsersync.reload]);
}
});