Expose matchFiles API as 'getMatchingFiles'
This commit is contained in:
parent
f6155f89da
commit
27d074d203
|
@ -4715,6 +4715,62 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ts {
|
namespace ts {
|
||||||
|
export interface FileSystemEntries {
|
||||||
|
/**
|
||||||
|
* The file names discovered within a parent directory. Each entry includes the base name and extension of the file, but does
|
||||||
|
* not include the parent path.
|
||||||
|
*/
|
||||||
|
readonly files: readonly string[];
|
||||||
|
/**
|
||||||
|
* The directory names discovered within a parent directory. Each entry includes the base name and extension of the file, but
|
||||||
|
* does not include the parent path.
|
||||||
|
*/
|
||||||
|
readonly directories: readonly string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FileMatcherHost {
|
||||||
|
useCaseSensitiveFileNames: boolean;
|
||||||
|
getCurrentDirectory(): string;
|
||||||
|
/**
|
||||||
|
* Gets the accessible file and directory names within a path, grouped by their kind.
|
||||||
|
* @param path The directory from which to retrieve entries.
|
||||||
|
*/
|
||||||
|
getAccessibleFileSystemEntries(path: string): FileSystemEntries;
|
||||||
|
realpath?(path: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FileMatcherOptions {
|
||||||
|
/** The set of extensions used to match files. */
|
||||||
|
extensions?: readonly string[];
|
||||||
|
/** A set of glob paths that should be excluded from the result. */
|
||||||
|
exclude?: readonly string[];
|
||||||
|
/** A set of glob paths that should be included in the result. */
|
||||||
|
include?: readonly string[];
|
||||||
|
/** The maximum depth at which to stop traversing the file system. */
|
||||||
|
depth?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds matching files based on the provided options.
|
||||||
|
* @param path The directory in which to start matching.
|
||||||
|
* @param options The options used to control matching.
|
||||||
|
* @param host The host used to traverse the file system.
|
||||||
|
* @returns The fully qualified paths of the matching files.
|
||||||
|
*/
|
||||||
|
export function getMatchingFiles(path: string, options: FileMatcherOptions, host: FileMatcherHost): string[] {
|
||||||
|
return matchFiles(
|
||||||
|
path,
|
||||||
|
options.extensions,
|
||||||
|
options.exclude,
|
||||||
|
options.include,
|
||||||
|
host.useCaseSensitiveFileNames,
|
||||||
|
host.getCurrentDirectory(),
|
||||||
|
options.depth,
|
||||||
|
path => host.getAccessibleFileSystemEntries(path),
|
||||||
|
path => host.realpath ? host.realpath(path) : path
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function getDefaultLibFileName(options: CompilerOptions): string {
|
export function getDefaultLibFileName(options: CompilerOptions): string {
|
||||||
switch (options.target) {
|
switch (options.target) {
|
||||||
case ScriptTarget.ESNext:
|
case ScriptTarget.ESNext:
|
||||||
|
@ -8164,11 +8220,6 @@ namespace ts {
|
||||||
return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
|
return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FileSystemEntries {
|
|
||||||
readonly files: ReadonlyArray<string>;
|
|
||||||
readonly directories: ReadonlyArray<string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FileMatcherPatterns {
|
export interface FileMatcherPatterns {
|
||||||
/** One pattern for each "include" spec. */
|
/** One pattern for each "include" spec. */
|
||||||
includeFilePatterns: ReadonlyArray<string> | undefined;
|
includeFilePatterns: ReadonlyArray<string> | undefined;
|
||||||
|
|
|
@ -3233,6 +3233,46 @@ declare namespace ts {
|
||||||
function sortAndDeduplicateDiagnostics<T extends Diagnostic>(diagnostics: ReadonlyArray<T>): SortedReadonlyArray<T>;
|
function sortAndDeduplicateDiagnostics<T extends Diagnostic>(diagnostics: ReadonlyArray<T>): SortedReadonlyArray<T>;
|
||||||
}
|
}
|
||||||
declare namespace ts {
|
declare namespace ts {
|
||||||
|
interface FileSystemEntries {
|
||||||
|
/**
|
||||||
|
* The file names discovered within a parent directory. Each entry includes the base name and extension of the file, but does
|
||||||
|
* not include the parent path.
|
||||||
|
*/
|
||||||
|
readonly files: readonly string[];
|
||||||
|
/**
|
||||||
|
* The directory names discovered within a parent directory. Each entry includes the base name and extension of the file, but
|
||||||
|
* does not include the parent path.
|
||||||
|
*/
|
||||||
|
readonly directories: readonly string[];
|
||||||
|
}
|
||||||
|
interface FileMatcherHost {
|
||||||
|
useCaseSensitiveFileNames: boolean;
|
||||||
|
getCurrentDirectory(): string;
|
||||||
|
/**
|
||||||
|
* Gets the accessible file and directory names within a path, grouped by their kind.
|
||||||
|
* @param path The directory from which to retrieve entries.
|
||||||
|
*/
|
||||||
|
getAccessibleFileSystemEntries(path: string): FileSystemEntries;
|
||||||
|
realpath?(path: string): string;
|
||||||
|
}
|
||||||
|
interface FileMatcherOptions {
|
||||||
|
/** The set of extensions used to match files. */
|
||||||
|
extensions?: readonly string[];
|
||||||
|
/** A set of glob paths that should be excluded from the result. */
|
||||||
|
exclude?: readonly string[];
|
||||||
|
/** A set of glob paths that should be included in the result. */
|
||||||
|
include?: readonly string[];
|
||||||
|
/** The maximum depth at which to stop traversing the file system. */
|
||||||
|
depth?: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Finds matching files based on the provided options.
|
||||||
|
* @param path The directory in which to start matching.
|
||||||
|
* @param options The options used to control matching.
|
||||||
|
* @param host The host used to traverse the file system.
|
||||||
|
* @returns The fully qualified paths of the matching files.
|
||||||
|
*/
|
||||||
|
function getMatchingFiles(path: string, options: FileMatcherOptions, host: FileMatcherHost): string[];
|
||||||
function getDefaultLibFileName(options: CompilerOptions): string;
|
function getDefaultLibFileName(options: CompilerOptions): string;
|
||||||
function textSpanEnd(span: TextSpan): number;
|
function textSpanEnd(span: TextSpan): number;
|
||||||
function textSpanIsEmpty(span: TextSpan): boolean;
|
function textSpanIsEmpty(span: TextSpan): boolean;
|
||||||
|
|
40
tests/baselines/reference/api/typescript.d.ts
vendored
40
tests/baselines/reference/api/typescript.d.ts
vendored
|
@ -3233,6 +3233,46 @@ declare namespace ts {
|
||||||
function sortAndDeduplicateDiagnostics<T extends Diagnostic>(diagnostics: ReadonlyArray<T>): SortedReadonlyArray<T>;
|
function sortAndDeduplicateDiagnostics<T extends Diagnostic>(diagnostics: ReadonlyArray<T>): SortedReadonlyArray<T>;
|
||||||
}
|
}
|
||||||
declare namespace ts {
|
declare namespace ts {
|
||||||
|
interface FileSystemEntries {
|
||||||
|
/**
|
||||||
|
* The file names discovered within a parent directory. Each entry includes the base name and extension of the file, but does
|
||||||
|
* not include the parent path.
|
||||||
|
*/
|
||||||
|
readonly files: readonly string[];
|
||||||
|
/**
|
||||||
|
* The directory names discovered within a parent directory. Each entry includes the base name and extension of the file, but
|
||||||
|
* does not include the parent path.
|
||||||
|
*/
|
||||||
|
readonly directories: readonly string[];
|
||||||
|
}
|
||||||
|
interface FileMatcherHost {
|
||||||
|
useCaseSensitiveFileNames: boolean;
|
||||||
|
getCurrentDirectory(): string;
|
||||||
|
/**
|
||||||
|
* Gets the accessible file and directory names within a path, grouped by their kind.
|
||||||
|
* @param path The directory from which to retrieve entries.
|
||||||
|
*/
|
||||||
|
getAccessibleFileSystemEntries(path: string): FileSystemEntries;
|
||||||
|
realpath?(path: string): string;
|
||||||
|
}
|
||||||
|
interface FileMatcherOptions {
|
||||||
|
/** The set of extensions used to match files. */
|
||||||
|
extensions?: readonly string[];
|
||||||
|
/** A set of glob paths that should be excluded from the result. */
|
||||||
|
exclude?: readonly string[];
|
||||||
|
/** A set of glob paths that should be included in the result. */
|
||||||
|
include?: readonly string[];
|
||||||
|
/** The maximum depth at which to stop traversing the file system. */
|
||||||
|
depth?: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Finds matching files based on the provided options.
|
||||||
|
* @param path The directory in which to start matching.
|
||||||
|
* @param options The options used to control matching.
|
||||||
|
* @param host The host used to traverse the file system.
|
||||||
|
* @returns The fully qualified paths of the matching files.
|
||||||
|
*/
|
||||||
|
function getMatchingFiles(path: string, options: FileMatcherOptions, host: FileMatcherHost): string[];
|
||||||
function getDefaultLibFileName(options: CompilerOptions): string;
|
function getDefaultLibFileName(options: CompilerOptions): string;
|
||||||
function textSpanEnd(span: TextSpan): number;
|
function textSpanEnd(span: TextSpan): number;
|
||||||
function textSpanIsEmpty(span: TextSpan): boolean;
|
function textSpanIsEmpty(span: TextSpan): boolean;
|
||||||
|
|
Loading…
Reference in a new issue