import os from 'node:os'; import path from 'node:path'; /** * Resolves a given file path, supporting tilde expansion for home directories. * * If the input path starts with a tilde followed by a path separator (e.g., * "~/"), it will be expanded to the user's home directory. Otherwise, the input * path will be resolved to an absolute path using `path.resolve()`. * * @param input - The file path to resolve, which may include a tilde for home * directory expansion. * @returns The resolved absolute file path. */ export function resolvePath(input: string): string { return input.startsWith(`~${path.sep}`) ? path.join(os.homedir(), input.slice(1 + path.sep.length)) : path.resolve(input); }