UNPKG

typescript-cp

Version:
111 lines (110 loc) 3.85 kB
/// <reference types="node" /> import * as fs from 'fs'; import { ParsedCommandLine } from 'typescript'; import { Config, TsProject } from './types'; export declare enum console_colors { Reset = "\u001B[0m", Bright = "\u001B[1m", Dim = "\u001B[2m", Underscore = "\u001B[4m", Blink = "\u001B[5m", Reverse = "\u001B[7m", Hidden = "\u001B[8m", FgBlack = "\u001B[30m", FgRed = "\u001B[31m", FgGreen = "\u001B[32m", FgYellow = "\u001B[33m", FgBlue = "\u001B[34m", FgMagenta = "\u001B[35m", FgCyan = "\u001B[36m", FgWhite = "\u001B[37m", BgBlack = "\u001B[40m", BgRed = "\u001B[41m", BgGreen = "\u001B[42m", BgYellow = "\u001B[43m", BgBlue = "\u001B[44m", BgMagenta = "\u001B[45m", BgCyan = "\u001B[46m", BgWhite = "\u001B[47m", FgBrightBlack = "\u001B[90m", FgBrightRed = "\u001B[91m", FgBrightGreen = "\u001B[92m", FgBrightYellow = "\u001B[93m", FgBrightBlue = "\u001B[94m", FgBrightMagenta = "\u001B[95m", FgBrightCyan = "\u001B[96m", FgBrightWhite = "\u001B[97m", BgBrightBlack = "\u001B[100m", BgBrightRed = "\u001B[101m", BgBrightGreen = "\u001B[102m", BgBrightYellow = "\u001B[103m", BgBrightBlue = "\u001B[104m", BgBrightMagenta = "\u001B[105m", BgBrightCyan = "\u001B[106m", BgBrightWhite = "\u001B[107m" } /** * Returns the complete, resolved configuration object */ export declare function get_config(): Promise<Config>; /** * Finds the `project` config file in `currentDir` and parses it with Typescript's own parser * @param currentDir * @param project */ export declare function get_ts_config(currentDir: string, project: string): ParsedCommandLine; /** * Returns the internal project descriptor of a TS project that doesn't have project references * @param options */ export declare function get_ts_project_paths(options: Config): TsProject; /** * Returns the internal project descriptor of a TS project that has project references * @param options */ export declare function get_ts_projects_paths(options: Config): TsProject[]; /** * Combines the exclude pattern in the tsconfig file and the TSCP `config.ignored_files` * @param config * @param projects */ export declare function get_ignore_list(config: Config, projects: TsProject | TsProject[]): string[]; /** * Displays a colored log in the stdout * @param msg * @param color */ export declare function color_log(msg: string, color: typeof console_colors[keyof typeof console_colors]): string; /** * Makes sure that the given folder (or the parent folder of a file) exists - creates if not * @param p {string} */ export declare function validate_path(p: string): Promise<void>; /** * Error-safe `fs.lstat` - returns stats if the file exists, otherwise null * @param file_path */ export declare function get_file_stats(file_path: string): Promise<fs.Stats | void>; /** * Deletes the `file_path` file. Doesn't throw error if the file doesn't exist. * @param file_path */ export declare function remove_file_or_directory(file_path: string): Promise<boolean>; /** * Reads the content of the `source_path` file, applies the loaders on its content, and writes the processed content to `destination_path` * @param source_path * @param destination_path * @param config */ export declare function copy_file_or_directory(source_path: string, destination_path: string, config: Config): Promise<void>; /** * Returns a Promise that resolves automatically after `ms` * @param ms */ export declare function sleep(ms: number): Promise<unknown>; /** * Converts your path `p` to POSIX format irrespective of whether you're already on POSIX platforms, or on win32 * @param p path string * @see https://stackoverflow.com/a/63251716/3111787 */ export declare function definitely_posix(p: string): string;