forked from irok/kinnosuke-time-recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
114 lines (102 loc) · 2.49 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*global require */
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var merge = require('event-stream').merge;
var del = require('del');
var bower = require('bower');
var subtask = function(name, fn_task, cb) {
$.util.log('run "' + name + '"');
var cb_ = function(err) {
$.util.log('end "' + name + '"');
if (typeof cb === 'function') {
return cb(err);
}
};
var stream = fn_task(cb_);
if (stream) {
return stream.on('end', cb_);
}
};
/**
* Dafault
*/
gulp.task('default', ['watch']);
/**
* Watch
*/
gulp.task('watch', function() {
gulp.watch('html/*', ['htmlhint']);
gulp.watch('js/*', ['jshint']);
});
/**
* Lint
*/
function htmlhint() {
return gulp.src('html/*')
.pipe($.htmlhint())
.pipe($.htmlhint.reporter());
}
function jshint() {
return gulp.src('js/*')
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'));
}
gulp.task('htmlhint', htmlhint);
gulp.task('jshint', jshint);
gulp.task('lint', function() {
return merge(
subtask('htmlhint', htmlhint),
subtask('jshint', jshint)
);
});
/**
* Build
*/
function prepare() {
return merge(
gulp.src('manifest.json')
.pipe(gulp.dest('tmp/')),
gulp.src('html/*')
.pipe(gulp.dest('tmp/html/')),
gulp.src('images/*')
.pipe(gulp.dest('tmp/images/')),
gulp.src('js/*')
.pipe(gulp.dest('tmp/js/')),
gulp.src('vendor/*')
.pipe(gulp.dest('tmp/vendor/'))
);
}
function zip() {
return gulp.src('tmp/**')
.pipe($.zip('KinnosukeTimeRecorder.zip'))
.pipe(gulp.dest('./'));
}
function clean(cb) {
del(['tmp/', 'KinnosukeTimeRecorder/'], cb);
}
gulp.task('prepare', prepare);
gulp.task('zip', ['prepare'], zip);
gulp.task('zip_', zip);
gulp.task('clean', clean);
gulp.task('build', ['lint'], function(done) {
subtask('prepare', prepare, function() {
subtask('zip', zip, function() {
subtask('clean', clean, done);
});
});
});
/**
* Init
*/
gulp.task('init', function(done) {
bower.commands.install().on('end', function() {
del(['vendor/'], function() {
gulp.src([
'bower_components/crypto-js-evanvosberg/build/rollups/aes.js',
'bower_components/jquery/dist/jquery.min.js'
])
.pipe(gulp.dest('vendor/'))
.on('end', done);
});
});
});