This repository has been archived by the owner on May 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
85 lines (72 loc) · 2.13 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
73
74
75
76
77
78
79
80
81
82
83
84
85
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var seq = require('run-sequence');
gulp.task('bump', function(){
var _type = gulp.env.type || 'patch';
return gulp.src(['./package.json',
'./bower.json'])
.pipe($.bump({type:_type, indent: 4 }))
.pipe(gulp.dest('./'));
});
gulp.task('default', function(done){
seq('clean',
'scripts',
'lint',
'test',
done);
});
gulp.task('scripts', function(done){
seq('scripts:browser',
'scripts:npm',
done);
});
gulp.task('scripts:browser', function(){
return gulp.src(['lib/**/*.js', '!lib/f.js'])
.pipe($.using())
.pipe($.wrap('//<%= file.relative %>\n<%= contents %>\n'))
.pipe($.concat('dashbars.js'))
.pipe($.wrap({src:'lib/wrap.js.txt'}, {modules:'dash, p, s, n, d'}))
.pipe(gulp.dest('dist/'))
.pipe($.using())
.pipe($.uglify())
.pipe($.rename('dashbars.min.js'))
.pipe(gulp.dest('dist/'))
.pipe($.using());
});
gulp.task('scripts:npm', function(){
return gulp.src('lib/**/*.js')
.pipe($.using())
.pipe($.using())
.pipe($.wrap('//<%= file.relative %>\n<%= contents %>\n'))
.pipe($.concat('index.js'))
.pipe($.wrap({src:'lib/wrap.js.txt'}, {modules:'dash, p, s, n, d, f'}))
.pipe(gulp.dest('dist/'))
.pipe($.using());
});
gulp.task('clean', function(done) {
require('del')('dist/', done);
});
gulp.task('lint', function(){
return gulp.src(['lib/**/*.js'])
.pipe($.jshint('.jshintrc'))
.pipe($.jshint.reporter('default'));
});
gulp.task('test', function() {
return gulp.src('test/**/*-test.js')
.pipe($.using())
.pipe($.mocha({
reporter: 'spec'
}));
});
// Watch
gulp.task('watch', ['default'], function(done){
gulp.watch('dist/**/*.js', ['default']);
done();
});
gulp.task('publish', function(done){
seq('publish:npm', done);
});
gulp.task('publish:npm', function (done) {
require("child_process").spawn('npm', ['publish'], { stdio: 'inherit' }).on('close', done);
});