Create a build script for tagging the current build

This commit is contained in:
mmcwilliams 2020-05-19 17:04:47 -04:00
parent f52b1cc861
commit f03f83f33e
1 changed files with 31 additions and 0 deletions

31
app/scripts/build.js Normal file
View File

@ -0,0 +1,31 @@
'use strict';
const fs = require('fs')
const uuid = require('uuid').v4
const PACKAGE = require('../package.json')
const INDEX = './www/index.html'
function patch (versionStr) {
const parts = versionStr.split('.');
const patch = parseInt(parts[2])
return `${parts[0]}.${parts[1]}.${patch+1}`
}
async function main () {
const build = uuid()
const short = build.split('-')[0]
const index = fs.readFileSync(INDEX, 'utf8')
const lines = index.split('\n')
let output
for (let i = 0; i < lines.length; i++) {
if (lines[i].indexOf('id="version"') !== -1) {
lines[i] = ` <div id="version">v${PACKAGE.version} build ${short}</div>`
}
}
output = lines.join('\n')
fs.writeFileSync(INDEX, output, 'utf8')
}
main()