UNPKG

969 BJavaScriptView Raw
1/**
2 * 打包任务
3 * @author lukezhu
4 * @date 2016-03-24
5 */
6
7var combiner = require('stream-combiner2');
8var moment = require('moment');
9
10module.exports = function(gulp, $, conf) {
11 // gulp pack 以时间为版本命名文件
12 // gulp pack -v 1.1.0 可指定版本号
13 gulp.task('pack', function() {
14 var version = $.util.env.v ? $.util.env.v : moment().format('YYMMDDHHmm');
15 var packageName = [conf.name, version].join('_');
16
17 var combined = combiner.obj([
18 gulp.src([
19 conf.parsePwd([conf.dist, '/**/*'].join(''))
20 ]),
21 $.zip([packageName, 'zip'].join('.')),
22 gulp.dest(conf.parsePwd(conf.package))
23 ]);
24
25 combined.on('error', console.error.bind(console));
26
27 combined.on('end', function() {
28 $.util.log(['Package Success: ', packageName, '.zip has been created on ', conf.package].join(''));
29 });
30
31 return combined;
32 });
33}