| 69 | } |
| 70 | |
| 71 | function prepareBinDirectory(binaryName) { |
| 72 | const binDir = path.join(__dirname, "bin") |
| 73 | const targetPath = path.join(binDir, binaryName) |
| 74 | |
| 75 | // Ensure bin directory exists |
| 76 | if (!fs.existsSync(binDir)) { |
| 77 | fs.mkdirSync(binDir, { recursive: true }) |
| 78 | } |
| 79 | |
| 80 | // Remove existing binary/symlink if it exists |
| 81 | if (fs.existsSync(targetPath)) { |
| 82 | fs.unlinkSync(targetPath) |
| 83 | } |
| 84 | |
| 85 | return { binDir, targetPath } |
| 86 | } |
| 87 | |
| 88 | function symlinkBinary(sourcePath, binaryName) { |
| 89 | const { targetPath } = prepareBinDirectory(binaryName) |