forked from ThinkingStudio/fastjson_ref_resolver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (59 loc) · 1.92 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
var gulp = require('gulp');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var del = require('del');
var version = '0.0.1';
var prj_name = 'fastjson_ref_resolver';
var prj_src_name = 'fastjson_ref_resolver.src';
var src_path = './fastjson_ref_resolver.src.js';
var tgt_path = './fastjson_ref_resolver.js';
var test_file = 'test.js';
var test_path = './test';
gulp.task('lint-main', function() {
return gulp.src(src_path)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('lint-test', function() {
return gulp.src(test_path)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('minify', function () {
gulp.src(src_path)
.pipe(uglify())
.pipe(rename(tgt_path))
.pipe(gulp.dest('./'));
});
gulp.task('clean-test', function(cb) {
console.log("Cleaning test dir ...");
del([test_path + '/**'], cb);
})
gulp.task('test-prepare', function() {
console.log("Preparing test dir ...");
return gulp.src(test_file)
.pipe(replace(/TESTSRC/g, prj_src_name))
.pipe(gulp.dest(test_path));
});
gulp.task('test', ['test-prepare'], function() {
console.log("running mocha ...")
return gulp.src(test_path + '/' + test_file, {read: false})
.pipe(mocha({reporter: 'dot'}));
});
gulp.task('test-build-prepare', ['clean-test'], function() {
console.log("Preparing test dir for build ...");
return gulp.src(test_file)
.pipe(replace(/TESTSRC/g, prj_name))
.pipe(gulp.dest(test_path));
});
gulp.task('test-build', ['minify', 'test-build-prepare'], function() {
console.log("running mocha ...")
return gulp.src(test_path + '/' + test_file, {read: false})
.pipe(mocha({reporter: 'dot'}));
});
gulp.task('build', ['test-build']);
gulp.task('default', ['lint-main', 'lint-test', 'test']);