replace-in-file
Version:
A simple utility to quickly replace text in one or more files.
22 lines (21 loc) • 888 B
TypeScript
import type { ParsedConfig, From, FromValue, To, ReplaceResult } from '../types.ts';
/**
* Get replacement helper
*/
export declare function getReplacement(replace: To | To[], i: number): To | null;
/**
* Escape string to make it safe for use in a regex
*/
export declare function escapeRegex(string: FromValue): FromValue;
/**
* Helper to make replacements
*/
export declare function makeReplacements(contents: string, from: From | From[], to: To | To[], file: string, count?: boolean): [ReplaceResult, string];
/**
* Helper to replace in a single file (sync)
*/
export declare function replaceSync(source: string, from: From | From[], to: To | To[], config: ParsedConfig): ReplaceResult;
/**
* Helper to replace in a single file (async)
*/
export declare function replaceAsync(source: string, from: From | From[], to: To | To[], config: ParsedConfig): Promise<ReplaceResult>;