mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-05 23:13:06 +00:00
debug pathselector for non-existing paths
This commit is contained in:
parent
574d4febe2
commit
7fa7820a53
@ -30,6 +30,7 @@ import { ConfigMenu } from "./ui/configMenu.js";
|
|||||||
import { PathSelector } from "./utils/pathSelector.js";
|
import { PathSelector } from "./utils/pathSelector.js";
|
||||||
import { NumberSelector } from "./utils/numberSelector.js";
|
import { NumberSelector } from "./utils/numberSelector.js";
|
||||||
import { MenuLoop } from "./utils/menuLoop.js";
|
import { MenuLoop } from "./utils/menuLoop.js";
|
||||||
|
import { DataDirMover } from "./utils/dataDirMover.js";
|
||||||
|
|
||||||
async function showNavigationMenu() {
|
async function showNavigationMenu() {
|
||||||
console.log("\n");
|
console.log("\n");
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import {
|
|||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
codexExe: "",
|
codexExe: "",
|
||||||
// User-selected config options:
|
// User-selected config options:
|
||||||
codexPath: getCodexBinPath(),
|
codexInstallPath: getCodexBinPath(),
|
||||||
dataDir: getCodexDataDirDefaultPath(),
|
dataDir: getCodexDataDirDefaultPath(),
|
||||||
logsDir: getCodexLogsDefaultPath(),
|
logsDir: getCodexLogsDefaultPath(),
|
||||||
storageQuota: 8 * 1024 * 1024 * 1024,
|
storageQuota: 8 * 1024 * 1024 * 1024,
|
||||||
|
|||||||
14
src/utils/command.js
Normal file
14
src/utils/command.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { exec } from "child_process";
|
||||||
|
import { promisify } from "util";
|
||||||
|
|
||||||
|
export const execAsync = promisify(exec);
|
||||||
|
|
||||||
|
export async function runCommand(command) {
|
||||||
|
try {
|
||||||
|
const { stdout, stderr } = await execAsync(command);
|
||||||
|
return stdout;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error:", error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -140,8 +140,13 @@ export class PathSelector {
|
|||||||
|
|
||||||
getSubDirOptions = () => {
|
getSubDirOptions = () => {
|
||||||
const fullPath = this.combine(this.currentPath);
|
const fullPath = this.combine(this.currentPath);
|
||||||
const entries = this.fs.readDir(fullPath);
|
try {
|
||||||
return entries.filter((entry) => this.isSubDir(entry));
|
const entries = this.fs.readDir(fullPath);
|
||||||
|
return entries.filter((entry) => this.isSubDir(entry));
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
downOne = async () => {
|
downOne = async () => {
|
||||||
|
|||||||
@ -101,6 +101,16 @@ describe("PathSelector", () => {
|
|||||||
expect(mockFsService.readDir).toHaveBeenCalledWith(mockStartPath);
|
expect(mockFsService.readDir).toHaveBeenCalledWith(mockStartPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("handles non-existing paths", async () => {
|
||||||
|
mockFsService.readDir.mockImplementationOnce(() => { throw new Error("A!"); });
|
||||||
|
|
||||||
|
await pathSelector.downOne();
|
||||||
|
|
||||||
|
expect(mockUiService.showInfoMessage).toHaveBeenCalledWith(
|
||||||
|
"There are no subdirectories here."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("can navigate to a subdirectory", async () => {
|
it("can navigate to a subdirectory", async () => {
|
||||||
const subdir = "subdir1";
|
const subdir = "subdir1";
|
||||||
mockFsService.readDir.mockReturnValue([subdir]);
|
mockFsService.readDir.mockReturnValue([subdir]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user