gen-version.ts 616 B

1234567891011121314151617181920212223242526
  1. import { writeFile } from 'fs/promises'
  2. import path from 'path'
  3. import consola from 'consola'
  4. import { epRoot } from '@element-plus/build-utils'
  5. import pkg from '../packages/element-plus/package.json' // need to be checked
  6. function getVersion() {
  7. const tagVer = process.env.TAG_VERSION
  8. if (tagVer) {
  9. return tagVer.startsWith('v') ? tagVer.slice(1) : tagVer
  10. } else {
  11. return pkg.version
  12. }
  13. }
  14. const version = getVersion()
  15. async function main() {
  16. consola.info(`Version: ${version}`)
  17. await writeFile(
  18. path.resolve(epRoot, 'version.ts'),
  19. `export const version = '${version}'\n`
  20. )
  21. }
  22. main()