forked from Yomguithereal/baobab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (47 loc) · 1.35 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
header = require('gulp-header'),
replace = require('gulp-replace'),
transform = require('vinyl-transform'),
browserify = require('browserify'),
pkg = require('./package.json');
// Files
var files = ['./index.js', './src/*.js', './test/**/*.js'];
// Gremlins
gulp.task('gremlins', function() {
return gulp.src(files[1])
.pipe(replace(' ', ' '))
.pipe(gulp.dest('./src'));
});
// Linting
gulp.task('lint', function() {
return gulp.src(files)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Testing
gulp.task('test', ['gremlins'], function() {
return gulp.src('./test/endpoint.js')
.pipe(mocha({reporter: 'spec'}));
});
// Building
gulp.task('build', function() {
var bundle = transform(function(filename) {
return browserify({
entries: filename,
standalone: 'Baobab',
fullPaths: false
}).bundle();
});
return gulp.src('./index.js')
.pipe(bundle)
.pipe(uglify())
.pipe(header('/* baobab.js - Version: ' + pkg.version + ' - Author: Yomguithereal (Guillaume Plique) */\n'))
.pipe(rename('baobab.min.js'))
.pipe(gulp.dest('./build'));
});
// Default
gulp.task('default', ['lint', 'test', 'build']);