logseq/scripts/get-pkg-version.js

29 lines
746 B
JavaScript
Raw Permalink Normal View History

2021-11-28 02:01:06 +00:00
// This script file simply outputs the version in the package.json.
// It is used as a helper by the continuous integration
const path = require('path')
const process = require('process')
2021-11-28 02:01:06 +00:00
const fs = require('fs')
2021-11-28 02:01:06 +00:00
const content = fs.readFileSync(
path.join(__dirname, '../src/main/frontend/version.cljs')
)
const pattern = /\(defonce version "(.*?)"\)/g
const match = pattern.exec(content)
let ver = '0.0.1'
if (match) {
ver = match[1]
} else {
console.error('Could not find version in version.cljs')
process.exit(1)
}
if (process.argv[2] === 'nightly' || process.argv[2] === '') {
const today = new Date()
console.log(
2022-12-02 19:28:21 +00:00
ver + '-nightly.' + today.toISOString().split('T')[0].replaceAll('-', '')
)
} else {
console.log(ver)
}