From 14c13f161340970a24c48dba5d14c85cc7d866b0 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 25 Jun 2025 11:29:35 -0700 Subject: [PATCH] fix: correct name for darwin-amd64 --- bin.js | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/bin.js b/bin.js index d7a2229..ef5c4dc 100755 --- a/bin.js +++ b/bin.js @@ -1,24 +1,34 @@ #!/usr/bin/env node -const { spawn } = require('child_process'); -const path = require('path'); -const fs = require('fs'); -const os = require('os'); +const { spawn } = require("child_process"); +const path = require("path"); +const fs = require("fs"); +const os = require("os"); // Determine platform and architecture const platform = os.platform(); -const arch = os.arch(); +let arch = os.arch(); + +// Map architecture for consistency with binary naming +if (platform === "darwin" && arch === "x64") { + arch = "amd64"; +} // Map OS and architecture to binary name let binaryName; -if (platform === 'win32') { - binaryName = 'rules-cli.exe'; +if (platform === "win32") { + binaryName = "rules-cli.exe"; } else { - binaryName = 'rules-cli'; + binaryName = "rules-cli"; } // Construct path to the binary -const binaryPath = path.join(__dirname, 'bin', `${platform}-${arch}`, binaryName); +const binaryPath = path.join( + __dirname, + "bin", + `${platform}-${arch}`, + binaryName +); // Check if binary exists if (!fs.existsSync(binaryPath)) { @@ -27,9 +37,9 @@ if (!fs.existsSync(binaryPath)) { } // Make binary executable (not needed on Windows) -if (platform !== 'win32') { +if (platform !== "win32") { try { - fs.chmodSync(binaryPath, '755'); + fs.chmodSync(binaryPath, "755"); } catch (error) { console.error(`Failed to make binary executable: ${error.message}`); process.exit(1); @@ -37,13 +47,15 @@ if (platform !== 'win32') { } // Execute the binary with all arguments passed through -const childProcess = spawn(binaryPath, process.argv.slice(2), { stdio: 'inherit' }); +const childProcess = spawn(binaryPath, process.argv.slice(2), { + stdio: "inherit", +}); -childProcess.on('error', (error) => { +childProcess.on("error", (error) => { console.error(`Failed to start binary: ${error.message}`); process.exit(1); }); -childProcess.on('close', (code) => { +childProcess.on("close", (code) => { process.exit(code); -}); \ No newline at end of file +});