forked from redhat-developer/vscode-xml
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
69 lines (60 loc) · 2.22 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
'use strict';
const gulp = require('gulp');
const cp = require('child_process');
const fse = require('fs-extra');
const glob = require('glob');
const server_dir = '../lemminx';
gulp.task('build_server', function (done) {
cp.execSync(mvnw() + " clean verify -DskipTests", { cwd: server_dir, stdio: [0, 1, 2] });
gulp.src(server_dir + '/org.eclipse.lemminx/target/org.eclipse.lemminx-uber.jar')
.pipe(gulp.dest('./server'));
done();
});
gulp.task('build_server_with_binary', function (done) {
cp.execSync(mvnw() + " clean verify -DskipTests -Dnative", { cwd: server_dir, stdio: [0, 1, 2] });
gulp.src([server_dir + '/org.eclipse.lemminx/target/org.eclipse.lemminx-uber.jar', server_dir + '/org.eclipse.lemminx/target/lemminx-*'])
.pipe(gulp.dest('./server'))
.on('end', function () {
glob.Glob('./server/lemminx-*.txt', (_er, txtfiles) => {
fse.removeSync(txtfiles[0]);
glob.Glob('./server/lemminx-*-*', (_err, binfiles) => {
fse.moveSync(binfiles[0], './server/lemminx-' + (isWin() ? 'win32.exe' : (isMac() ? 'osx-x86_64' : 'linux')), { overwrite: true });
});
});
});
done();
});
gulp.task('prepare_pre_release', function (done) {
const json = JSON.parse(fse.readFileSync("./package.json").toString());
const stableVersion = json.version.match(/(\d+)\.(\d+)\.(\d+)/);
const major = stableVersion[1];
const minor = stableVersion[2];
const date = new Date();
const month = date.getMonth() + 1;
const day = date.getDate();
const hours = date.getHours();
const patch = `${date.getFullYear()}${prependZero(month)}${prependZero(day)}${prependZero(hours)}`;
const insiderPackageJson = Object.assign(json, {
version: `${major}.${minor}.${patch}`,
});
fse.writeFileSync("./package.json", JSON.stringify(insiderPackageJson, null, 2));
done();
});
function isWin() {
return /^win/.test(process.platform);
}
function isMac() {
return /^darwin/.test(process.platform);
}
function isLinux() {
return /^linux/.test(process.platform);
}
function mvnw() {
return isWin() ? "mvnw.cmd" : server_dir + "/mvnw";
}
function prependZero(number) {
if (number > 99) {
throw "Unexpected value to prepend with zero";
}
return `${number < 10 ? "0" : ""}${number}`;
}