- refactored resolvePath to have parity with resolveInode and take in ShellState instead of FileSystem and cwd

- reverted change "removed inode 0 from tree traversal results"
This commit is contained in:
2026-08-30 09:58:23 +02:00
parent d0f8376244
commit 4776232377
2 changed files with 14 additions and 17 deletions
+3 -8
View File
@@ -1,6 +1,5 @@
import type { CommandDescriptor, CommandOutput } from "@core/command";
import type { CommandIO } from "@core/command_io";
import type { FileSystem } from "@core/filesystem/filesystem";
import { createErrorResult, createSuccessResult } from "@core/result";
import { getCurrentSession } from "@core/session_manager";
import { ShellState, withCwd } from "@core/shell_state";
@@ -40,7 +39,7 @@ async function main(
} else if (args[0] === "-") {
inode = session.pwd;
} else {
const result = safeResolvePath(state.filesystem, session.cwd, args[0]);
const result = safeResolvePath(state, args[0]);
if (result.type === "error") {
return {
state,
@@ -76,13 +75,9 @@ async function main(
result: createSuccessResult(COMMAND_NAME),
};
function safeResolvePath(
fs: FileSystem,
cwd: number,
path: string,
): { type: "success"; inode: number } | { type: "error" } {
function safeResolvePath(state: ShellState, path: string): { type: "success"; inode: number } | { type: "error" } {
try {
return { type: "success", inode: resolvePath(fs, cwd, path) };
return { type: "success", inode: resolvePath(state, path) };
} catch {
return { type: "error" };
}