gluegun
Version:
A delightful toolkit for building Node-powered CLIs.
35 lines (34 loc) • 1.09 kB
TypeScript
export interface GluegunPatchingPatchOptions {
insert?: string;
before?: string | RegExp;
after?: string | RegExp;
replace?: string | RegExp;
delete?: string | RegExp;
force?: boolean;
}
export interface GluegunPatching {
/**
* Checks if a string or pattern exists in a file.
*/
exists(filename: string, findPattern: string | RegExp): Promise<boolean>;
/**
* Updates a file.
*/
update(filename: string, callback: (contents: any) => any): Promise<string | object | boolean>;
/**
* Appends to the end of a file.
*/
append(filename: string, contents: string): Promise<string | boolean>;
/**
* Prepends to the start of a files.
*/
prepend(filename: string, contents: string): Promise<string | boolean>;
/**
* Replaces part of a file.
*/
replace(filename: string, searchFor: string, replaceWith: string): Promise<string | boolean>;
/**
* Makes a patch inside file.
*/
patch(filename: string, ...options: GluegunPatchingPatchOptions[]): Promise<string | boolean>;
}