mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-02 13:33:11 +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 { NumberSelector } from "./utils/numberSelector.js";
|
||||
import { MenuLoop } from "./utils/menuLoop.js";
|
||||
import { DataDirMover } from "./utils/dataDirMover.js";
|
||||
|
||||
async function showNavigationMenu() {
|
||||
console.log("\n");
|
||||
|
||||
@ -10,7 +10,7 @@ import {
|
||||
const defaultConfig = {
|
||||
codexExe: "",
|
||||
// User-selected config options:
|
||||
codexPath: getCodexBinPath(),
|
||||
codexInstallPath: getCodexBinPath(),
|
||||
dataDir: getCodexDataDirDefaultPath(),
|
||||
logsDir: getCodexLogsDefaultPath(),
|
||||
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 = () => {
|
||||
const fullPath = this.combine(this.currentPath);
|
||||
const entries = this.fs.readDir(fullPath);
|
||||
return entries.filter((entry) => this.isSubDir(entry));
|
||||
try {
|
||||
const entries = this.fs.readDir(fullPath);
|
||||
return entries.filter((entry) => this.isSubDir(entry));
|
||||
}
|
||||
catch {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
downOne = async () => {
|
||||
|
||||
@ -101,6 +101,16 @@ describe("PathSelector", () => {
|
||||
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 () => {
|
||||
const subdir = "subdir1";
|
||||
mockFsService.readDir.mockReturnValue([subdir]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user