UNPKG

doxdox-core

Version:
95 lines (94 loc) 3.15 kB
import { Package } from './types'; /** * Finds file in path. * * console.log(await findFileInPath('./', 'package.json')); * console.log(await findFileInPath('../', 'package.json')); * console.log(await findFileInPath('~/git/github/doxdox/', '.package.json')); * * @param {string} [input] Directory to check for file. * @param {string?} [fileName = 'package.json'] File name to check for. * @return {Promise<string | null>} Path to package.json file. * @public */ export declare const findFileInPath: (input: string, fileName?: string) => Promise<string | null>; /** * Finds the closest node_module folder in the parent directories. * * @param {string} [currentDirectory] Current directory. * @param {number} [maxDepth] Optional max depth. * @return {Promise<string | null>} Path to node_modules directory. * @public */ export declare const findParentNodeModules: (currentDirectory: string, maxDepth?: number) => Promise<string | null>; /** * Returns basic information from a projects package file. * * @return {Promise<Package>} Basic information from a package file. * @public */ export declare const getProjectPackage: (cwd: string) => Promise<Package>; /** * Get the root directory of the package, supplied path or URL. * * @param {string?} [url] Optional path or URL. * @return {string} Directory path. * @public */ export declare const getRootDirPath: (url?: string) => string; /** * Checks to see if path is a directory. * * @param {string} [path] Path to check. * @return {Promise<boolean>} * @public */ export declare const isDirectory: (path: string) => Promise<boolean>; /** * Checks to see if path is a file. * * @param {string} [path] Path to check. * @return {Promise<boolean>} * @public */ export declare const isFile: (path: string) => Promise<boolean>; /** * Return information about pattern if found within contents. * * @param {string} [content] Full contents to search for pattern in. * @param {string} [pattern] Pattern to look for in contents. * @return {{ start?: number; end?: number; matched: boolean }} * @public */ export declare const multiLinePatternMatch: (content: string, pattern: string, offset?: number) => { start?: number; end?: number; matched: boolean; }; /** * Parse config key/value pairs from raw CLI flags. * * console.log(await parseConfigFromCLI([['-c', 'key=value']])); * * @param {[string, string | boolean][]} rawFlags Raw flags from the CLI. * @return {{ [key in string]: string | boolean }} Configs key/value pairs. * @public */ export declare const parseConfigFromCLI: (rawFlags: [string, string | boolean][]) => { [key in string]: string | boolean; }; /** * Parse contents of ignore file. * * console.log(await parseIgnoreConfig('node_modules/')); * * @param {string} [contents] Contents of ignore file. * @return {string[]} List of ignored paths and files. * @public */ export declare const parseIgnoreConfig: (contents: string) => string[]; /** * Slugify a value for use as an anchor. * * @return {string} Contents to slugify. * @public */ export declare const slugify: (contents: string) => string;