UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

70 lines (69 loc) 2.62 kB
import { FileSystemHost } from "./../fileSystem"; export declare class FileUtils { private static standardizeSlashesRegex; private constructor(); /** * Ensure the directory exists synchronously. * @param host - File system host. * @param dirPath - Directory path. */ static ensureDirectoryExistsSync(host: FileSystemHost, dirPath: string): void; /** * Ensure the directory exists asynchronously. * @param host - File system host. * @param dirPath - Directory path. */ static ensureDirectoryExists(host: FileSystemHost, dirPath: string): Promise<void>; /** * Joins the paths. * @param paths - Paths to join. */ static pathJoin(...paths: string[]): string; /** * Gets the standardized absolute path. * @param fileSystem - File system. * @param fileOrDirPath - Path to standardize. * @param relativeBase - Base path to be relative from. */ static getStandardizedAbsolutePath(fileSystem: FileSystemHost, fileOrDirPath: string, relativeBase?: string): string; /** * Gets the directory path. * @param fileOrDirPath - Path to get the directory name from. */ static getDirPath(fileOrDirPath: string): string; /** * Gets the base name. * @param fileOrDirPath - Path to get the base name from. */ static getBaseName(fileOrDirPath: string): string; /** * Changes all back slashes to forward slashes. * @param fileOrDirPath - Path. */ static standardizeSlashes(fileOrDirPath: string): string; /** * Checks if a file path matches a specified search string. * @param filePath - File path. * @param searchString - Search string. */ static filePathMatches(filePath: string | null, searchString: string | null): boolean; /** * Reads a file or returns false if the file doesn't exist. * @param fileSystem - File System. * @param filePath - Path to file. * @param encoding - File encoding. */ static readFileOrNotExists(fileSystem: FileSystemHost, filePath: string, encoding: string): Promise<string | false>; /** * Reads a file synchronously or returns false if the file doesn't exist. * @param fileSystem - File System. * @param filePath - Path to file. * @param encoding - File encoding. */ static readFileOrNotExistsSync(fileSystem: FileSystemHost, filePath: string, encoding: string): string | false; /** * Gets the text with a byte order mark. * @param text - Text. */ static getTextWithByteOrderMark(text: string): string; }