UNPKG

@stryke/path

Version:

A package containing various utilities that expand the functionality of NodeJs's built-in `path` module

40 lines (39 loc) 1.24 kB
/** * Resolve the parent path of the provided path. * * @param path - The path to resolve. * @param count - The number of parent directories to traverse. * @returns The parent path of the provided path. */ export declare const resolveParentPath: (path: string, count?: number) => string; /** * Options for the `getParentPath` function. */ export interface GetParentPathOptions { /** * Whether to ignore the case of the file names when checking for existence. * * @defaultValue true */ ignoreCase: boolean; /** * Whether to skip the current working directory when checking for the file. * * @defaultValue false */ skipCwd: boolean; /** * The type of target to look for. * * @defaultValue "both" */ targetType: "file" | "directory" | "both"; } /** * Get the first parent path that has a file or directory with the provided name. * * @param name - The name (or names) of the file to look for in the parent paths. * @param cwd - The current working directory. * @returns The first parent path that exists. */ export declare const getParentPath: (name: string | string[], cwd: string, options?: Partial<GetParentPathOptions>) => string | undefined;