2
0

preinstall.mjs 734 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env node
  2. import fs from "fs"
  3. import path from "path"
  4. import os from "os"
  5. import { fileURLToPath } from "url"
  6. const __dirname = path.dirname(fileURLToPath(import.meta.url))
  7. function main() {
  8. if (os.platform() !== "win32") {
  9. console.log("Non-Windows platform detected, skipping preinstall")
  10. return
  11. }
  12. const binDir = path.join(__dirname, "bin")
  13. const unixScript = path.join(binDir, "opencode")
  14. console.log("Windows detected: Configuring bin scripts for Windows")
  15. if (fs.existsSync(unixScript)) {
  16. console.log("Removing Unix shell script from bin/")
  17. fs.unlinkSync(unixScript)
  18. }
  19. }
  20. try {
  21. main()
  22. } catch (error) {
  23. console.error("Preinstall script error:", error.message)
  24. process.exit(0)
  25. }