-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
78 lines (63 loc) · 2.36 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
/* eslint-env node */
var gulp = require('gulp');
var zip = require('gulp-zip');
var bump = require('gulp-bump');
var semver = require('semver');
var chromeExtLoc = 'Extensions/Chrome Extension';
var ffExtLoc = 'Extensions/Firefox Extension';
gulp.task('scripts', function () {
return gulp.src('Source/*.js')
.pipe(gulp.dest(chromeExtLoc + '/Source'))
.pipe(gulp.dest(ffExtLoc + '/Source'));
});
gulp.task('styles', function () {
return gulp.src('Source/*.css')
.pipe(gulp.dest(chromeExtLoc + '/Source'))
.pipe(gulp.dest(ffExtLoc + '/Source'));
});
gulp.task('compresszipff', gulp.series('scripts', 'styles', function () {
return gulp.src(ffExtLoc + '/Source/*')
.pipe(zip('CancerTTV Firefox.xpi'))
.pipe(gulp.dest('Extensions/Firefox Extension'));
}));
gulp.task('compresszipchrome', gulp.series('scripts', 'styles', function () {
return gulp.src(chromeExtLoc + '/Source/*')
.pipe(zip('CancerTTV Chrome.zip'))
.pipe(gulp.dest(chromeExtLoc + ''));
}));
var fs = require('fs');
var getPackageJson = function (arg) {
return JSON.parse(fs.readFileSync(arg, 'utf8'));
};
var version = 'minor';
if (process.argv.indexOf('--patch') > -1)
version = 'patch';
gulp.task('bumpversionpackage', function () {
var pkg = getPackageJson('package.json');
var newVer = semver.inc(pkg.version, version);
return gulp.src('package.json')
.pipe(bump({version: newVer}))
.pipe(gulp.dest(''));
});
gulp.task('bumpversionchrome', function () {
var pkg = getPackageJson(chromeExtLoc + '/Source/manifest.json');
var newVer = semver.inc(pkg.version, version);
return gulp.src(chromeExtLoc + '/Source/manifest.json')
.pipe(bump({version: newVer}))
.pipe(gulp.dest(chromeExtLoc + '/Source'));
});
gulp.task('bumpversionff', function () {
var pkg = getPackageJson(ffExtLoc + '/Source/manifest.json');
var newVer = semver.inc(pkg.version, version);
return gulp.src(ffExtLoc + '/Source/manifest.json')
.pipe(bump({version: newVer}))
.pipe(gulp.dest(ffExtLoc + '/Source'));
});
gulp.task(
'bumpversion',
gulp.series('bumpversionpackage', 'bumpversionchrome', 'bumpversionff')
);
gulp.task('watch', function () {
gulp.watch('Source/*', ['styles', 'scripts']);
});
gulp.task('default', gulp.series('scripts', 'compresszipff', 'compresszipchrome'));