move-binary.js 858 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. /**
  5. * This script is used to rename the binary with the platform specific postfix.
  6. * When `tauri build` is ran, it looks for the binary name appended with the platform specific postfix.
  7. */
  8. const execa = require('execa')
  9. const fs = require('fs')
  10. let extension = ''
  11. if (process.platform === 'win32') {
  12. extension = '.exe'
  13. }
  14. async function main() {
  15. const rustInfo = (await execa('rustc', ['-vV'])).stdout
  16. const targetTriple = /host: (\S+)/g.exec(rustInfo)[1]
  17. if (!targetTriple) {
  18. console.error('Failed to determine platform target triple')
  19. }
  20. fs.renameSync(
  21. `src-tauri/binaries/app${extension}`,
  22. `src-tauri/binaries/app-${targetTriple}${extension}`
  23. )
  24. }
  25. main().catch((e) => {
  26. throw e
  27. })