You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
608 B

4 years ago
4 years ago
4 years ago
  1. import pkg from './package.json'
  2. import { execSync } from 'child_process'
  3. export default {
  4. define: {
  5. APP_TITLE: pkg.name,
  6. APP_VERSION: buildVersion(),
  7. }
  8. }
  9. // FUNCTIONS
  10. //----------
  11. function buildVersion(): string {
  12. const version = pkg.version
  13. if (!isGitCommand()) {
  14. return version
  15. }
  16. const dirty = Number(execSync("git status -s | wc -l").toString())
  17. return dirty > 0 ? `${version}${dirty}` : version
  18. }
  19. function isGitCommand(): boolean {
  20. try {
  21. execSync("command -v git")
  22. return true
  23. } catch (e) {
  24. return false
  25. }
  26. }