Module

x/ts_morph/common/ts_morph_common.d.ts>FileUtils

TypeScript Compiler API wrapper for static analysis and programmatic code changes.
Go to Latest
class FileUtils
import { FileUtils } from "https://dotland.deno.dev/x/ts_morph@21.0.0/common/ts_morph_common.d.ts";

Utilities for working with files.

Constructors

new
private
FileUtils()

Static Properties

readonly
ENOENT: string

Static Methods

getBaseName(fileOrDirPath: StandardizedFilePath): string

Gets the last portion of the path.

Gets the descendant directories of the specified directory.

getDirPath<T extends string>(fileOrDirPath: T): T

Gets the directory path.

getExtension(fileOrDirPath: StandardizedFilePath): string

Gets the extension of the file name.

Gets the parent most paths out of the list of paths.

Gets the relative path from one absolute path to another.

getStandardizedAbsolutePath(
fileSystem: FileSystemHost,
fileOrDirPath: string,
relativeBase?: string,
): StandardizedFilePath

Gets the standardized absolute path.

getTextWithByteOrderMark(text: string): string

Gets the text with a byte order mark.

isNegatedGlob(glob: string): boolean

Gets if the glob is a negated glob.

isNotExistsError(err: any): boolean

Gets if the error is a file not found or directory not found error.

isRootDirPath(dirOrFilePath: string): boolean

Gets if the path is for the root directory.

pathEndsWith(fileOrDirPath: string | undefined, endsWithPath: string | undefined): boolean

Checks if a path ends with a specified search path.

pathIsAbsolute(fileOrDirPath: string): boolean

Gets if the path is absolute.

pathJoin<T extends string>(basePath: T, ...paths: string[]): T

Joins the paths.

pathStartsWith(fileOrDirPath: string | undefined, startsWithPath: string | undefined): boolean

Checks if a path starts with a specified search path.

readFileOrNotExists(
fileSystem: FileSystemHost,
encoding: string,
): Promise<string | false>

Reads a file or returns false if the file doesn't exist.

readFileOrNotExistsSync(
fileSystem: FileSystemHost,
encoding: string,
): string | false

Reads a file synchronously or returns false if the file doesn't exist.

standardizeSlashes<T extends string>(fileOrDirPath: T): T

Changes all back slashes to forward slashes.

toAbsoluteGlob(glob: string, cwd: string): string

Gets the glob as absolute.