⚡ Improving performance
This commit is contained in:
36
build.js
36
build.js
@@ -1,12 +1,10 @@
|
||||
const axios = require("axios");
|
||||
const fs = require("fs");
|
||||
const {
|
||||
spawnSync
|
||||
} = require("child_process");
|
||||
const { spawnSync } = require("child_process");
|
||||
const runCommand = (command, args) =>
|
||||
spawnSync(command, args)
|
||||
.stdout.toString()
|
||||
.replace(/\n/g, "");
|
||||
.stdout.toString()
|
||||
.replace(/\n/g, "");
|
||||
|
||||
const FAIL_ON_ERROR = false;
|
||||
const PW_BUILD_DATA_DIR = "./.postwoman";
|
||||
@@ -21,18 +19,24 @@ try {
|
||||
|
||||
let version = {};
|
||||
// Get the current version name as the tag from Git.
|
||||
version.name = process.env.TRAVIS_TAG || runCommand("git", ["tag --sort=committerdate | tail -1"]);
|
||||
version.name =
|
||||
process.env.TRAVIS_TAG ||
|
||||
runCommand("git", ["tag --sort=committerdate | tail -1"]);
|
||||
|
||||
// FALLBACK: If version.name was unset, let's grab it from GitHub.
|
||||
if (!version.name) {
|
||||
version.name = (await axios
|
||||
.get("https://api.github.com/repos/liyasthomas/postwoman/releases")
|
||||
// If we can't get it from GitHub, we'll resort to getting it from package.json
|
||||
.catch((ex) => ({
|
||||
data: [{
|
||||
tag_name: require("./package.json").version
|
||||
}]
|
||||
}))).data[0]["tag_name"];
|
||||
version.name = (
|
||||
await axios
|
||||
.get("https://api.github.com/repos/liyasthomas/postwoman/releases")
|
||||
// If we can't get it from GitHub, we'll resort to getting it from package.json
|
||||
.catch(ex => ({
|
||||
data: [
|
||||
{
|
||||
tag_name: require("./package.json").version
|
||||
}
|
||||
]
|
||||
}))
|
||||
).data[0]["tag_name"];
|
||||
}
|
||||
|
||||
// Get the current version hash as the short hash from Git.
|
||||
@@ -41,8 +45,8 @@ try {
|
||||
version.variant =
|
||||
process.env.TRAVIS_BRANCH ||
|
||||
runCommand("git", ["branch"])
|
||||
.split("* ")[1]
|
||||
.split(" ")[0] + (IS_DEV_MODE ? " - DEV MODE" : "");
|
||||
.split("* ")[1]
|
||||
.split(" ")[0] + (IS_DEV_MODE ? " - DEV MODE" : "");
|
||||
if (["", "master"].includes(version.variant)) {
|
||||
delete version.variant;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user