Download src/utils/host-runtime-binaries.js from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 2.69 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/utils/host-runtime-binaries.js
- Command line
-
hf download hf://VanyaJ/bada-terminal/src/utils/host-runtime-binaries.js
-
curl -L -o host-runtime-binaries.js https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/utils/host-runtime-binaries.js
2.69 kB
| // ์ค๋ช ๋ฌธ์: docs/specs/bada-code-quality.md (v1.0.0) | |
| // CLI์ GUI์ ์คํ ํ์ผ ํ์์ ๊ณต์ ํ๋ฉฐ ์ ธ ๋ณด๊ฐ ์์ด ์กฐํํ๋ค. | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const os = require('os'); | |
| const { execFileSync } = require('child_process'); | |
| function findOnPath(command) { | |
| try { | |
| const locator = process.platform === 'win32' ? 'where.exe' : 'which'; | |
| const output = execFileSync(locator, [command], { | |
| encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 3000, windowsHide: true | |
| }); | |
| const lines = output.split(/\r?\n/).map(line => line.trim()).filter(Boolean); | |
| if (process.platform === 'win32') { | |
| // Windows npm ๊ธ๋ก๋ฒ ์ค์น ๊ฒฝ๋ก(%APPDATA%\npm\opencode)์ ํ์ฅ์ ์๋ POSIX ์คํฌ๋ฆฝํธ๋ณด๋ค .exe/.cmd/.bat๋ฅผ ์ฐ์ ์ ํํ๋ค. | |
| const winExec = lines.find(line => /\.(exe|cmd|bat|com)$/i.test(line) && fs.existsSync(line)); | |
| if (winExec) return winExec; | |
| } | |
| const first = lines[0]; | |
| return first && fs.existsSync(first) ? first : null; | |
| } catch { | |
| // ์ ํ ์คํ ํ์ผ์ด ์์ผ๋ฉด ๋ค์ ํ๋ณด๋ฅผ ์ฌ์ฉํ๋ค. ์๊ฒฉ์ด๋ ํ๊ฒฝ์ ์ถ๋ ฅํ์ง ์๋๋ค. | |
| return null; | |
| } | |
| } | |
| function resolveNodeBin() { | |
| const home = os.homedir(); | |
| const candidates = [ | |
| '/opt/homebrew/bin/node', '/usr/local/bin/node', '/usr/bin/node', | |
| path.join(home, '.nvm/current/bin/node'), 'C:\\Program Files\\nodejs\\node.exe' | |
| ]; | |
| return candidates.find(candidate => fs.existsSync(candidate)) | |
| || findOnPath('node') || findOnPath('bun') | |
| || (!process.versions.electron ? process.execPath : 'node'); | |
| } | |
| function resolveOpencodeBin() { | |
| const override = process.env.OPENWORK_OPENCODE_BIN; | |
| if (override && fs.existsSync(override)) return override; | |
| const home = os.homedir(); | |
| const candidates = process.platform === 'win32' | |
| ? [ | |
| path.join(home, '.opencode', 'bin', 'opencode.exe'), | |
| path.join(home, '.opencode', 'bin', 'opencode.cmd'), | |
| path.join(home, 'AppData', 'Local', 'Microsoft', 'WinGet', 'Links', 'opencode.exe'), | |
| path.join(home, 'scoop', 'shims', 'opencode.exe'), | |
| path.join(home, '.bun', 'bin', 'opencode.exe'), | |
| path.join(home, 'AppData', 'Roaming', 'npm', 'opencode.cmd'), | |
| path.join(home, '.codeagent', 'bin', 'opencode.exe') | |
| ] | |
| : [ | |
| path.join(home, '.opencode', 'bin', 'opencode'), | |
| path.join(home, '.codeagent', 'bin', 'opencode'), | |
| '/opt/homebrew/bin/opencode', '/usr/local/bin/opencode' | |
| ]; | |
| return candidates.find(candidate => fs.existsSync(candidate)) || findOnPath('opencode') || 'opencode'; | |
| } | |
| module.exports = { resolveNodeBin, resolveOpencodeBin }; | |