UNPKG

@stryke/path

Version:

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

72 lines (71 loc) 2.77 kB
import type { Platform } from "@stryke/types/system"; export interface PackageResolvingOptions { /** * Paths to resolve the package from */ paths?: string[]; /** * Resolve path as linux (stand-in for unix/posix) or win32 */ platform?: Platform; } /** * Resolve the path to a specified module * * @param path - The path to the module * @param options - The options to use when resolving the module * @returns A promise for the path to the module */ export declare function resolve(path: string, options?: PackageResolvingOptions): Promise<string>; /** * Resolve the path to a specified module * * @param path - The path to the module * @param options - The options to use when resolving the module * @returns The path to the module or undefined */ export declare function resolveSync(path: string, options?: PackageResolvingOptions): string; /** * Resolve the path to a specified module with error handling * * @param name - The name of the module * @param options - The options to use when resolving the module * @returns A promise for the path to the module */ export declare function resolveSafe(name: string, options?: PackageResolvingOptions): Promise<string | undefined>; /** * Resolve the path to a specified module with error handling * * @param name - The name of the module * @param options - The options to use when resolving the module * @returns The path to the module or undefined */ export declare function resolveSafeSync(name: string, options?: PackageResolvingOptions): string | undefined; /** * Import a module from a specified path * * @param path - The path to the module * @returns The module */ export declare function importModule<T = any>(path: string): Promise<T>; /** * Resolve the path to a specified package asynchronously * * @remarks * This path points to the root of the package, which is usually the directory containing the `package.json` file. Please note: this path does not include the `package.json` file itself. * * @param name - The name of the module * @returns A promise for the module or undefined */ export declare function resolvePackage(name: string, options?: PackageResolvingOptions): Promise<string | undefined>; /** * Resolve the path to a specified package synchronously * * @remarks * This path points to the root of the package, which is usually the directory containing the `package.json` file. Please note: this path does not include the `package.json` file itself. * * @param name - The name of the module * @param options - The options to use when resolving the module * @returns The module or undefined */ export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions): Promise<string | undefined>;