UNPKG

@stryke/fs

Version:

A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.

94 lines (93 loc) 3.44 kB
import { ResolveOptions } from "./resolve.mjs"; import { Range } from "semver"; import { PackageJson } from "@stryke/types/package-json"; import { PackageManager } from "@stryke/types/package-manager"; //#region src/package-fns.d.ts /** * Get the package manager used in the project * * @param dir - The path to the project * @returns The package manager used in the project */ declare function getPackageManager(dir?: any): PackageManager; /** * Get package info * * @param name - The name of the package * @param options - The options to use when resolving the package * @returns The package info */ declare function getPackageInfo(name: string, options?: ResolveOptions): Promise<{ name: string; version: string | undefined; rootPath: string; packageJsonPath: string; packageJson: PackageJson; } | undefined>; /** * Get the package info from the package.json file * * @param cwd - The current working directory * @returns The package info */ declare function loadPackageJson(cwd?: any): Promise<PackageJson | null>; interface PackageExistsOptions { /** * The current working directory */ cwd?: string; } interface PackageMatchesOptions extends PackageExistsOptions { /** * The version range of the package to check */ version?: string | Range; } /** * Check if a package is listed in the package.json file * * @param name - The name of the package * @param cwd - The current working directory * @returns An indicator specifying if the package is listed */ declare function isPackageListed(name: string, cwd?: string): Promise<boolean>; /** * Check if a package is listed in the package.json file * * @param name - The name of the package * @param options - The options to use when checking if the package is listed * @returns An indicator specifying if the package is listed */ declare function isPackageListed(name: string, options?: PackageExistsOptions): Promise<boolean>; interface GetPackageListingReturn { version: string; type: "dependencies" | "devDependencies"; } /** * Return the package version and dependency type listed in the package.json file * * @param name - The name of the package * @param cwdOrOptions - The current working directory or options to use when checking if the package is listed * @returns The version and type of the package if listed, otherwise undefined */ declare function getPackageListing(name: string, cwdOrOptions?: string | PackageExistsOptions): Promise<GetPackageListingReturn | undefined>; /** * Check if a package version matches a specific version range * * @param name - The name of the package * @param version - The version to check against * @param cwd - The current working directory * @returns An indicator specifying if the package version matches the range */ declare function doesPackageMatch(name: string, version: string, cwd?: string): Promise<boolean>; /** * Check if a package exists * * @param name - The name of the package * @param options - The options to use when resolving the package * @returns An indicator specifying if the package exists */ declare function isPackageExists(name: string, options?: ResolveOptions): boolean; //#endregion export { GetPackageListingReturn, PackageExistsOptions, PackageMatchesOptions, doesPackageMatch, getPackageInfo, getPackageListing, getPackageManager, isPackageExists, isPackageListed, loadPackageJson }; //# sourceMappingURL=package-fns.d.mts.map