This repository has been archived by the owner on Feb 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
81 lines (70 loc) · 2.19 KB
/
gulpfile.babel.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
var gulp = require('gulp'),
del = require('del'),
babel = require('gulp-babel'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
eslint = require('gulp-eslint'),
header = require('gulp-header'),
pkg = require('./package.json'),
mocha = require('gulp-mocha'),
webserver = require('gulp-webserver');
var babelPlugins = [
'check-es2015-constants',
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping',
['transform-es2015-classes', {loose: true}],
'transform-es2015-parameters',
'transform-es2015-template-literals',
'transform-es2015-modules-umd'
];
var paths = {
scripts: ['src/**/justgiving-apiclient.js'],
tests: ['tests/**/*.js']
};
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
gulp.task('clean', cb => del('./dist/justgiving-apiclient*', cb) );
gulp.task('build', ['build-full'], () =>
gulp.src('dist/justgiving-apiclient.js')
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest('dist'))
);
gulp.task('build-full', ['lint', 'clean'], () =>
gulp.src(paths.scripts)
.pipe(sourcemaps.init())
.pipe(babel({plugins: babelPlugins, moduleId: 'JustGiving'}))
.pipe(header(banner, { pkg : pkg } ))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'))
);
gulp.task('watch', () => {
gulp.watch(paths.scripts, ['test']);
gulp.watch(paths.tests, ['test']);
});
gulp.task('lint', () =>
gulp.src(paths.scripts)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError())
);
gulp.task('test', ['build'], () =>
gulp.src(['tests/*.js', 'dist/justgiving-apiclient.js'], { read: false })
.pipe(mocha())
);
gulp.task('webserver', () => {
// eg http://localhost:8000/examples/method-samples.html or http://localhost:8000/examples/chained.knockout.html
gulp.src('.')
.pipe(webserver({
livereload: true,
directoryListing: true
}));
});
gulp.task('default', ['watch', 'test', 'webserver'], () => {});