This commit is contained in:
Liyas Thomas
2020-05-19 19:50:27 +05:30
parent 9c0c80033f
commit 67ad59b80e
2 changed files with 17 additions and 20 deletions

View File

@@ -1,10 +1,7 @@
const axios = require("axios")
const fs = require("fs")
const { spawnSync } = require("child_process")
const runCommand = (command, args) =>
spawnSync(command, args)
.stdout.toString()
.replace(/\n/g, "")
const runCommand = (command, args) => spawnSync(command, args).stdout.toString().replace(/\n/g, "")
const FAIL_ON_ERROR = false
const PW_BUILD_DATA_DIR = "./.postwoman"
@@ -28,7 +25,7 @@ try {
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 => ({
.catch((ex) => ({
data: [
{
tag_name: require("./package.json").version,
@@ -39,16 +36,16 @@ try {
}
// Get the current version hash as the short hash from Git.
version.hash = runCommand("git", ["rev-parse", "--short", "HEAD"])
// version.hash = runCommand("git", ["rev-parse", "--short", "HEAD"])
// Get the 'variant' name as the branch, if it's not master.
version.variant =
process.env.TRAVIS_BRANCH ||
runCommand("git", ["branch"])
.split("* ")[1]
.split(" ")[0] + (IS_DEV_MODE ? " - DEV MODE" : "")
if (["", "master"].includes(version.variant)) {
delete version.variant
}
// version.variant =
// process.env.TRAVIS_BRANCH ||
// runCommand("git", ["branch"])
// .split("* ")[1]
// .split(" ")[0] + (IS_DEV_MODE ? " - DEV MODE" : "")
// if (["", "master"].includes(version.variant)) {
// delete version.variant
// }
// Write version data into a file
fs.writeFileSync(`${PW_BUILD_DATA_DIR}/version.json`, JSON.stringify(version))