Changed version scripts to run on win and macos as well

This commit is contained in:
RemixDev
2021-07-18 22:29:07 +02:00
parent 4604f2176e
commit 5f7a02a6f5
3 changed files with 26 additions and 2 deletions

6
scripts/reset-version.js Normal file
View File

@@ -0,0 +1,6 @@
const { execSync } = require('child_process')
const fs = require('fs')
let package = JSON.parse(fs.readFileSync('package.json'))
package.version = "0.0.0"
fs.writeFileSync('package.json', JSON.stringify(package, null, 2)+"\n")

18
scripts/set-version.js Normal file
View File

@@ -0,0 +1,18 @@
const { execSync } = require('child_process')
const fs = require('fs')
function generateVersion(){
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth();
const day = now.getDate();
const commitsNumber = String(execSync('git rev-list --count HEAD')).trim()
const commitHash = String(execSync('git rev-parse --short=10 HEAD')).trim()
return `${year}.${month}.${day}-r${commitsNumber}.${commitHash}`
}
let package = JSON.parse(fs.readFileSync('package.json'))
package.version = generateVersion()
fs.writeFileSync('package.json', JSON.stringify(package, null, 2)+"\n")