move-binary.js 716 B

12345678910111213141516171819202122232425262728
  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 rustInfo = (await execa('rustc', ['-vV'])).stdout
  13. const targetTriple = /host: (\S+)/g.exec(rustInfo)[1]
  14. if (!targetTriple) {
  15. console.error('Failed to determine platform target triple')
  16. }
  17. fs.renameSync(
  18. `src-tauri/binaries/app${extension}`,
  19. `src-tauri/binaries/app-${targetTriple}${extension}`
  20. )
  21. }
  22. main().catch((e) => {
  23. throw e
  24. })