forked from tzarskyz/letitbitjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
79 lines (71 loc) · 2.2 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
'use strict';
var browserify = require('browserify');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var sourceFile = './userjs.js';
var destFolder = './dist/';
var buildFolder = './build/';
var destFile = 'userjs.min.js';
var uglify = require('gulp-uglify');
var bufferify = require('vinyl-buffer');
var del = require('del');
var header = require('gulp-header');
var pkg = require('./package.json');
// userjs header
var banner = [
'// ==UserScript==',
'// @name ${name}',
'// @description ${desc}',
'// @version ${ver}',
'// @date ${date}',
'// @author ${author}',
'// @homepageURL https://github.com/ReklatsMasters/letitbitjs',
'// @updateURL https://openuserjs.org/install/${author}/${name}.user.js',
'// @include http://letitbit.net/download*',
'// @include http://*.letitbit.net/download*',
'// @include http://vip-file.com/download*',
'// @include http://*.vip-file.com/download*',
'// @include http://shareflare.net/download*',
'// @include http://*.shareflare.net/download*',
'// @grant GM_xmlhttpRequest',
'// @icon http://images.letitbit.net/favicon.ico',
'// @license ${lic}',
'// @copyright ${year}, ${author} (${mysite})',
'// ==/UserScript==',
'\n'
].join('\n');
var locals = {
name: pkg.name,
ver: pkg.version,
author: pkg.author,
date: new Date().toISOString().split('T')[0],
desc: pkg.description,
lic: pkg.license,
year: new Date().getFullYear(),
mysite: "https://github.com/ReklatsMasters"
};
gulp.task('clean:dist', function (cb) {
del([destFolder], cb);
});
gulp.task('clean:build', function (cb) {
del([buildFolder], cb);
});
gulp.task('dist', ['clean:dist'], function() {
return browserify(sourceFile)
.bundle()
.pipe(source(destFile))
.pipe(bufferify())
.pipe(uglify())
.pipe(header(banner, locals))
.pipe(gulp.dest(destFolder));
});
gulp.task('build', ['clean:build'], function() {
return browserify(sourceFile)
.bundle()
.pipe(source(destFile))
.pipe(bufferify())
.pipe(uglify())
.pipe(header(banner, locals))
.pipe(gulp.dest(buildFolder));
});
gulp.task('default', ['build']);