From 771888f427c0167b2193f8ab5947ec8d7e879c18 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 17 Feb 2025 12:35:54 +0100 Subject: [PATCH] Runs codex from correct path --- src/handlers/installationHandlers.js | 7 +++++-- src/handlers/nodeHandlers.js | 7 ++++--- src/main.js | 2 +- src/services/nodeService.js | 7 ++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/handlers/installationHandlers.js b/src/handlers/installationHandlers.js index 6236d70..7fdceb2 100644 --- a/src/handlers/installationHandlers.js +++ b/src/handlers/installationHandlers.js @@ -55,7 +55,9 @@ These information will be used for calculating various metrics that can eventual return agreement.toLowerCase() === 'y'; } -async function getCodexVersion(config) { +export async function getCodexVersion(config) { + if (config.codexExe.length < 1) return ""; + try { const version = await runCommand(`${config.codexExe} --version`); if (version.length < 1) throw new Error("Version info not found."); @@ -175,7 +177,8 @@ export async function installCodex(config, showNavigationMenu) { try { const version = await getCodexVersion(config); console.log(showSuccessMessage( - 'Codex is successfully installed!\n\n' + + 'Codex is successfully installed!\n' + + `Install path: "${config.codexExe}"\n\n` + `Version: ${version}` )); } catch (error) { diff --git a/src/handlers/nodeHandlers.js b/src/handlers/nodeHandlers.js index 5988935..1a74047 100644 --- a/src/handlers/nodeHandlers.js +++ b/src/handlers/nodeHandlers.js @@ -27,8 +27,8 @@ async function promptForWalletAddress() { return wallet || null; } -export async function runCodex(showNavigationMenu) { - const isInstalled = await isCodexInstalled(); +export async function runCodex(config, showNavigationMenu) { + const isInstalled = await isCodexInstalled(config); if (!isInstalled) { console.log(showErrorMessage('Codex is not installed. Please install Codex first using option 1 from the main menu.')); await showNavigationMenu(); @@ -65,7 +65,7 @@ export async function runCodex(showNavigationMenu) { nat = await runCommand('curl -s https://ip.codex.storage'); } - const executable = `codex`; + const executable = config.codexExe; const args = [ `--data-dir=datadir`, `--disc-port=${discPort}`, @@ -80,6 +80,7 @@ export async function runCodex(showNavigationMenu) { console.log(showInfoMessage( '🚀 Codex node is running...\n\n' + + 'If your firewall ask, be sure to allow Codex to receive connections. \n' + 'Please keep this terminal open. Start a new terminal to interact with the node.\n\n' + 'Press CTRL+C to stop the node' )); diff --git a/src/main.js b/src/main.js index 0759928..e43505e 100644 --- a/src/main.js +++ b/src/main.js @@ -109,7 +109,7 @@ export async function main() { await checkCodexInstallation(config, showNavigationMenu); break; case '2': - await runCodex(showNavigationMenu); + await runCodex(config, showNavigationMenu); return; case '3': await checkNodeStatus(showNavigationMenu); diff --git a/src/services/nodeService.js b/src/services/nodeService.js index bba61ff..810760b 100644 --- a/src/services/nodeService.js +++ b/src/services/nodeService.js @@ -2,6 +2,7 @@ import axios from 'axios'; import { runCommand } from '../utils/command.js'; import { showErrorMessage, showInfoMessage, showSuccessMessage } from '../utils/messages.js'; import os from 'os'; +import { getCodexVersion } from '../handlers/installationHandlers.js'; const platform = os.platform(); @@ -29,10 +30,10 @@ export async function isNodeRunning() { } } -export async function isCodexInstalled() { +export async function isCodexInstalled(config) { try { - await runCommand('codex --version'); - return true; + const version = await getCodexVersion(config); + return version.length > 0; } catch (error) { return false; }