move-binary.js 821 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * This script is used to rename the binary with the platform specific postfix.
  3. * When `tauri build` is ran, it looks for the binary name appended with the platform specific postfix.
  4. */
  5. const execa = require('execa')
  6. const fs = require('fs')
  7. let extension = ''
  8. if (process.platform === 'win32') {
  9. extension = '.exe'
  10. }
  11. async function main() {
  12. const rustTargetInfo = JSON.parse(
  13. (
  14. await execa(
  15. 'rustc',
  16. ['-Z', 'unstable-options', '--print', 'target-spec-json'],
  17. {
  18. env: {
  19. RUSTC_BOOTSTRAP: 1
  20. }
  21. }
  22. )
  23. ).stdout
  24. )
  25. const platformPostfix = rustTargetInfo['llvm-target']
  26. fs.renameSync(
  27. `src-tauri/binaries/app${extension}`,
  28. `src-tauri/binaries/app-${platformPostfix}${extension}`
  29. )
  30. }
  31. main().catch((e) => {
  32. throw e
  33. })