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