-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
46 lines (39 loc) · 1.33 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
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
replace = require('gulp-replace'),
del = require('del'),
mocha = require('gulp-mocha');
var info = require('./package.json'),
head = '/*! universal-diff v' + info.version + ' | ' + info.author.name + '(' + info.author.email + ') | Apache License(2.0) */\n';
var paths = {
dist: 'dist',
scripts: ['lib/head.js', 'lib/define.js', 'lib/core.js', 'lib/script.js', 'lib/string.js', 'lib/tail.js'],
tests: ['test/script.js', 'test/string.js']
};
// do test
gulp.task('test', function(){
return gulp.src(paths.tests, {read: false})
.pipe(mocha({ignoreLeaks: false}));
});
// clean dist folder
gulp.task('clean', function(cb) {
del([paths.dist], cb);
});
// build uncompressed result
gulp.task('build-dev', ['clean'], function() {
return gulp.src(paths.scripts)
.pipe(concat('diff.js'))
.pipe(replace(/\/\*[\s\S]*?\*\/\n/g, ''))
.pipe(replace(/^/g, head))
.pipe(gulp.dest(paths.dist));
});
// build compressed result
gulp.task('build', ['clean'], function() {
return gulp.src(paths.scripts)
.pipe(concat('diff.min.js'))
.pipe(uglify())
.pipe(replace(/^/g, head))
.pipe(gulp.dest(paths.dist));
});
gulp.task('default', ['build-dev', 'build']);