Runs codex from correct path

This commit is contained in:
Ben 2025-02-17 12:35:54 +01:00
parent 34121d9d1a
commit 771888f427
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
4 changed files with 14 additions and 9 deletions

View File

@ -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) {

View File

@ -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'
));

View File

@ -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);

View File

@ -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;
}