Skip to content

Commit

Permalink
update compile.js to allow dynamic versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
theamazingfedex committed Oct 7, 2022
1 parent 2339ba2 commit 9f08501
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions compile.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
const { compile } = require('nexe');
const { version } = require('./package.json');
const packageJson = require('./package.json');
const fs = require('fs');
const version = packageJson.version;

const args = process.argv.slice(2);
let [major, minor, patch, extra] = version.split('.');
[patch, extra = ''] = patch.split('-');
if (args.includes('major')) { major = Number(major) + 1; minor = 0; patch = 0; extra = ''; }
if (args.includes('minor')) { minor = Number(minor) + 1; patch = 0; extra = ''; }
if (args.includes('patch')) { patch = Number(patch) + 1; extra = ''; }
if (args.includes('beta')) { extra = '-beta' }
if (args.includes('alpha')) { extra = '-alpha' }
const newVersion = `${major}.${minor}.${patch}${extra}`;

compile({
input: './serve.js',
clean: args.includes('clean'),
build: args.includes('build'),
bundle: true,
output: `./release/mhmm-v${version}`,
name: `mhmm-v${version}`,
rc: { PRODUCTVERSION: `${version}` },
output: `./release/mhmm-v${newVersion}`,
name: `mhmm-v${newVersion}`,
rc: { PRODUCTVERSION: `${newVersion}` },
targets: ['windows'],
vcBuild: ['release'],
verbose: true,
// targets: ['windows-x64-14.15.3', 'windows-x86-14.15.3'],
temp: "./.nexe",
ico: "./public/favicon.ico",
resources: [
"./build",
// "./public",
],
}).then(() => {
console.log('compilation successful')
console.log('compilation successful');
if (version !== newVersion) {
fs.writeFileSync('./package.json', JSON.stringify({...packageJson, version: newVersion}, null, 2));
}
}).catch(err => {
console.error('compilation err: ', err);
})

0 comments on commit 9f08501

Please sign in to comment.