-
Notifications
You must be signed in to change notification settings - Fork 64
/
index.d.ts
32 lines (27 loc) · 995 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
declare module 'replace-in-file' {
function replaceInFile(config: ReplaceInFileConfig): Promise<ReplaceResult[]>;
function replaceInFile(config: ReplaceInFileConfig, cb: (error: Error, results: ReplaceResult[]) => void): void;
export default replaceInFile;
namespace replaceInFile {
export function sync(config: ReplaceInFileConfig): ReplaceResult[];
}
export interface ReplaceInFileConfig {
files: string | string[];
ignore: string | string[];
from: string | RegExp | string[] | RegExp[] | FromCallback;
to: string | string[] | ToCallback;
countMatches?: boolean;
allowEmptyPaths?: boolean,
disableGlobs?: boolean,
encoding?: string,
dry?:boolean
}
export interface ReplaceResult {
file: string;
hasChanged: boolean;
numMatches?: number,
numReplacements?: number,
}
}
type FromCallback = (file: string) => string | RegExp | string[] | RegExp[];
type ToCallback = (match: string, file: string) => string | string[];