-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
96 lines (89 loc) · 2.48 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
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var stripDebug = require('gulp-strip-debug');
var replace = require('gulp-replace');
var watch = require('gulp-watch');
var fs = require('fs');
var version = JSON.parse(fs.readFileSync('./package.json')).version;
var argv = require('yargs').argv;
var probes = {
// MODIFY THIS ARRAY FOR DEV MODE
dev: [
{
domain: "localhost",
protocol: "http://",
port: ":8000",
path: "",
probe: "/wallet/probe.html",
wallet: "/wallet/wallet.html"
}, {
domain: "localhost",
protocol: "http://",
port: ":8000",
path: "",
probe: "/wallet_swap/probe.html",
wallet: "/wallet_swap/wallet.html"
}
],
// MODIFY THIS ARRAY FOR PRODUCTION MODE
dist: [
{
domain: "bitcoin-e.org",
protocol: "https://",
port: ":443",
path: "",
probe: "/wallet/probe.html",
wallet: "/wallet/wallet.html"
}, {
domain: "bitcoin-e.org",
protocol: "https://",
port: ":443",
path: "",
probe: "/wallet_swap/probe.html",
wallet: "/wallet_swap/wallet.html"
}
]
}
function dist(dest) {
return gulp.src('BitcoinExpress.js')
.pipe(replace("###WELL_KNOWN_WALLETS###", JSON.stringify(probes.dist)))
.pipe(replace("###VERSION###", version))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify().on('error', function (e) {
console.log(e);
}))
.pipe(stripDebug())
.pipe(gulp.dest(dest));
}
function dev(dest) {
return gulp.src('BitcoinExpress.js')
.pipe(replace("###VERSION###", version))
.pipe(replace("###WELL_KNOWN_WALLETS###", JSON.stringify(probes.dev)))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(dest));
}
gulp.task('default', function () {
var dest = argv.dest || 'dist';
if ("watch" in argv) {
return watch('BitcoinExpress.js', function () {
var time = new Date();
var strTime = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
console.log('[' + strTime + '] File updated');
dist(dest);
});
}
return dist(dest);
});
gulp.task('build:dev', function () {
var dest = argv.dest || 'dist';
if ("watch" in argv) {
return watch('BitcoinExpress.js', function () {
var time = new Date();
var strTime = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
console.log('[' + strTime + '] File updated');
dev(dest);
});
}
return dev(dest);
});