forked from pubfood/pubfood
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
50 lines (44 loc) · 1.42 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
'use strict';
var gulp = require('gulp'),
pkg = require('./package.json'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream'),
eslint = require('gulp-eslint'),
header = require('gulp-header'),
mocha = require('gulp-mocha'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
uglify = require('gulp-uglify'),
exit = require('gulp-exit');
gulp.task('browserify-unit-tests', function() {
var b = browserify();
b.add('./test/unittestindex.js');
var bStream = b.bundle();
bStream.pipe(source('unittests.js'))
.pipe(gulp.dest('./test'));
});
gulp.task('test', function() {
return gulp.src(['./test/index.js'])
.pipe(mocha({reporter: 'spec'}))
.pipe(exit());
});
gulp.task('lint', function() {
return gulp.src(['src/**/*.js', 'test/**/*.js', 'gulpfile.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('build', function() {
var bundleStream = browserify([], pkg.browserify).bundle();
bundleStream
.pipe(source('pubfood.js'))
.pipe(buffer())
.pipe(header('/*! pubfood vAPP_VERSION | (c) pubfood | http://pubfood.org/LICENSE.txt */\n'))
.pipe(replace('APP_VERSION', pkg.version))
.pipe(gulp.dest('./build'))
.pipe(uglify({ preserveComments: 'some' }))
.pipe(rename('pubfood.min.js'))
.pipe(gulp.dest('./build'));
});
gulp.task('build-js', ['build']);