im a bit dumb

This commit is contained in:
Core 2022-05-02 05:38:37 +01:00
parent 561ee3fe82
commit a417e8680f
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6

View file

@ -3,24 +3,20 @@ if (!process.env['CIRCLECI']) {
return
}
let fs = require('fs')
const {readFileSync, writeFile} = require('fs')
const pkg = JSON.parse(readFileSync('package.json').toString());
let channel = process.env['CIRCLE_BRANCH'];
const data = fs.readFileSync('package.json');
const pkg = JSON.parse(data.toString());
let channel;
if (process.env['CIRCLE_BRANCH'] === 'lts') {
channel = 'latest'
} else if (process.env['CIRCLE_BRANCH'] === 'main') {
channel = 'beta'
} else if (process.env['CIRCLE_BRANCH'] === 'develop') {
channel = 'alpha'
} else {
channel = process.env['CIRCLE_BRANCH'] // It won't have auto update support
}
channel.split('/').join('-')
channel = channel.split('/').join('-')
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
const version = pkg.version.split('.');
@ -36,11 +32,13 @@ pkg.publish = {
"releaseType": "release"
}
let {exec} = require('child_process')
const {exec} = require('child_process')
exec('echo $APP_VERSION', {env: {'APP_VERSION': pkg.version}}, function (error, stdout, stderr) {
console.log(stdout, stderr, error);
});
fs.writeFile('package.json', JSON.stringify(pkg), err => {
writeFile('package.json', JSON.stringify(pkg), err => {
// error checking
if (err) throw err;
console.log(`VERSION CHANGED TO ${pkg.version}`);