-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathprepare-nightly-build.js
More file actions
29 lines (24 loc) · 926 Bytes
/
prepare-nightly-build.js
File metadata and controls
29 lines (24 loc) · 926 Bytes
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
const fs = require("fs");
const json = JSON.parse(fs.readFileSync("./package.json").toString());
const stableVersion = json.version.match(/(\d+)\.(\d+)\.(\d+)/);
if (!stableVersion) {
throw new Error(`Invalid stable version: ${json.version}`);
}
const major = stableVersion[1];
const minor = stableVersion[2];
function prependZero(number) {
if (number > 99) {
throw new Error("Unexpected value to prepend with zero");
}
return `${number < 10 ? "0" : ""}${number}`;
}
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}`,
preview: true,
});
fs.writeFileSync("./package.insiders.json", `${JSON.stringify(insiderPackageJson, null, 2)}\n`);