(hermescPath, locationName)
| 25 | } |
| 26 | |
| 27 | function setupSingleHermesc(hermescPath, locationName) { |
| 28 | const hermescDir = path.dirname(hermescPath); |
| 29 | const backupHermescPath = path.join(hermescDir, '_hermesc'); |
| 30 | const wrapperSourcePath = path.join(__dirname, 'hermesc-wrapper.js'); |
| 31 | |
| 32 | if (fs.existsSync(backupHermescPath)) { |
| 33 | console.log(`⏭️ [Hermesc Setup] ${locationName} already configured, skipping...`); |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | if (!fs.existsSync(hermescPath)) { |
| 38 | console.log(`ℹ️ [Hermesc Setup] ${locationName} hermesc not found at: ${hermescPath}`); |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | if (!fs.existsSync(wrapperSourcePath)) { |
| 43 | console.error(`❌ [Hermesc Setup] Wrapper script not found at: ${wrapperSourcePath}`); |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | try { |
| 48 | console.log(`🔧 [Hermesc Setup] Setting up hermesc wrapper for ${locationName}...`); |
| 49 | |
| 50 | fs.renameSync(hermescPath, backupHermescPath); |
| 51 | console.log(`✅ [Hermesc Setup] ${locationName}: Renamed hermesc -> _hermesc`); |
| 52 | |
| 53 | const shellScript = `#!/bin/bash |
| 54 | # Hermesc wrapper script - auto-generated |
| 55 | # This script calls the Node.js wrapper which handles post-processing |
| 56 | |
| 57 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| 58 | WRAPPER_SCRIPT="${wrapperSourcePath}" |
| 59 | |
| 60 | find_node() { |
| 61 | if command -v node >/dev/null 2>&1; then |
| 62 | command -v node |
| 63 | return 0 |
| 64 | fi |
| 65 | |
| 66 | local NODE_PATHS=( |
| 67 | "/usr/local/bin/node" |
| 68 | "/opt/homebrew/bin/node" |
| 69 | "$HOME/.nvm/versions/node/$(ls -t "$HOME/.nvm/versions/node" 2>/dev/null | head -1)/bin/node" |
| 70 | "/usr/bin/node" |
| 71 | ) |
| 72 | |
| 73 | for node_path in "\${NODE_PATHS[@]}"; do |
| 74 | if [ -x "$node_path" ]; then |
| 75 | echo "$node_path" |
| 76 | return 0 |
| 77 | fi |
| 78 | done |
| 79 | |
| 80 | echo "Error: node executable not found" >&2 |
| 81 | echo "Please ensure Node.js is installed and accessible" >&2 |
| 82 | exit 1 |
| 83 | } |
| 84 |
no test coverage detected