-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
48 lines (44 loc) · 1.18 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
const gulp = require('gulp'),
pfs = require('./scripts/lib/pfs'),
zip = require('gulp-vinyl-zip').zip,
pkg = require('pkg').exec;
gulp.task('build', async function(callback) {
try {
let version = await applyVersion();
await pkg(['.']);
await zipVmb(version);
}
catch(err) {
console.error(err);
}
callback();
});
function zipVmb(version) {
return new Promise((resolve, reject) => {
gulp.src(
[
'.template/**/*',
'.template-vmf/**/*',
'vmb.exe',
'mods/',
//'README.md',
'LICENSE'
],
{ base: '.' }
)
.pipe(zip(`vmb-${version}.zip`))
.pipe(gulp.dest('.'))
.on('end', () => resolve())
.on('error', (err) => {
console.log(err);
reject();
});
});
}
async function applyVersion() {
let config = await pfs.readFile('./package.json', 'utf-8');
config = JSON.parse(config);
let content = `module.exports = '${config.version}';\n`;
await pfs.writeFile('./scripts/version.js', content);
return config.version;
}