get-pkg-version.js 752 B

12345678910111213141516171819202122232425262728
  1. // This script file simply outputs the version in the package.json.
  2. // It is used as a helper by the continuous integration
  3. const path = require('path')
  4. const process = require('process')
  5. const fs = require('fs')
  6. const content = fs.readFileSync(
  7. path.join(__dirname, '../src/main/frontend/version.cljs')
  8. )
  9. const pattern = /\(defonce version "(.*?)"\)/g
  10. const match = pattern.exec(content)
  11. let ver = '0.0.1'
  12. if (match) {
  13. ver = match[1]
  14. } else {
  15. console.error('Could not find version in version.cljs')
  16. process.exit(1)
  17. }
  18. if (process.argv[2] === 'nightly' || process.argv[2] === '') {
  19. const today = new Date()
  20. console.log(
  21. ver + '-alpha+nightly.' + today.toISOString().split('T')[0].replaceAll('-', '')
  22. )
  23. } else {
  24. console.log(ver)
  25. }