Skip to content

Commit 24c2e51

Browse files
authored
Merge pull request #21 from continuedev/nate/amd64
fix: correct name for darwin-amd64
2 parents 05a84ff + 14c13f1 commit 24c2e51

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

bin.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
#!/usr/bin/env node
22

3-
const { spawn } = require('child_process');
4-
const path = require('path');
5-
const fs = require('fs');
6-
const os = require('os');
3+
const { spawn } = require("child_process");
4+
const path = require("path");
5+
const fs = require("fs");
6+
const os = require("os");
77

88
// Determine platform and architecture
99
const platform = os.platform();
10-
const arch = os.arch();
10+
let arch = os.arch();
11+
12+
// Map architecture for consistency with binary naming
13+
if (platform === "darwin" && arch === "x64") {
14+
arch = "amd64";
15+
}
1116

1217
// Map OS and architecture to binary name
1318
let binaryName;
14-
if (platform === 'win32') {
15-
binaryName = 'rules-cli.exe';
19+
if (platform === "win32") {
20+
binaryName = "rules-cli.exe";
1621
} else {
17-
binaryName = 'rules-cli';
22+
binaryName = "rules-cli";
1823
}
1924

2025
// Construct path to the binary
21-
const binaryPath = path.join(__dirname, 'bin', `${platform}-${arch}`, binaryName);
26+
const binaryPath = path.join(
27+
__dirname,
28+
"bin",
29+
`${platform}-${arch}`,
30+
binaryName
31+
);
2232

2333
// Check if binary exists
2434
if (!fs.existsSync(binaryPath)) {
@@ -27,23 +37,25 @@ if (!fs.existsSync(binaryPath)) {
2737
}
2838

2939
// Make binary executable (not needed on Windows)
30-
if (platform !== 'win32') {
40+
if (platform !== "win32") {
3141
try {
32-
fs.chmodSync(binaryPath, '755');
42+
fs.chmodSync(binaryPath, "755");
3343
} catch (error) {
3444
console.error(`Failed to make binary executable: ${error.message}`);
3545
process.exit(1);
3646
}
3747
}
3848

3949
// Execute the binary with all arguments passed through
40-
const childProcess = spawn(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
50+
const childProcess = spawn(binaryPath, process.argv.slice(2), {
51+
stdio: "inherit",
52+
});
4153

42-
childProcess.on('error', (error) => {
54+
childProcess.on("error", (error) => {
4355
console.error(`Failed to start binary: ${error.message}`);
4456
process.exit(1);
4557
});
4658

47-
childProcess.on('close', (code) => {
59+
childProcess.on("close", (code) => {
4860
process.exit(code);
49-
});
61+
});

0 commit comments

Comments
 (0)