@freephoenix888/find-and-replace-in-github-file-in-all-repositories
Version:
Find and replace text in github file in all repositories
35 lines (34 loc) • 1.2 kB
TypeScript
import { FindAndReplaceInGithubFileOptions } from '@freephoenix888/find-and-replace-in-github-file';
import { Octokit } from '@octokit/rest';
export interface FindAndReplaceInAllRepositoriesOptions extends Omit<FindAndReplaceInGithubFileOptions, 'repo'> {
/** Octokit instance for interacting with the GitHub API */
octokit: Octokit;
/** Owner of the GitHub repositories */
owner: string;
/**
* Callback function for handling errors.
*/
onError?: (error: Error) => void;
/**
* Delay in milliseconds between requests to the GitHub API.
*/
delayInMs?: number;
}
/**
* Finds and replaces text in a specific file across all repositories of a GitHub user.
*
* @example
* #### Find and replace text in a file in all repositories
```ts
const octokit = new Octokit({ auth: 'YOUR_PERSONAL_ACCESS_TOKEN' });
await findAndReplaceInAllRepositories({
octokit,
owner: 'username',
path: 'path/to/file.txt',
regex: /findMe/g,
replacement: 'replaceWithMe',
commitMessage: "Replaced 'findMe' with 'replaceWithMe'"
})
```
*/
export declare function findAndReplaceInAllRepositories(options: FindAndReplaceInAllRepositoriesOptions): Promise<void>;