Created
November 8, 2024 21:30
-
-
Save micaiah-effiong/88de9bf674a76fbc9393148b4ba658ab to your computer and use it in GitHub Desktop.
A function for expo-plugin that adds new lines to build gradle. Can be used to add lines to other files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const addToBuildGradle = ( | |
| newLine: string, | |
| anchor: RegExp | string, | |
| offset: number, | |
| buildGradle: string, | |
| ) => { | |
| const lines = buildGradle.split('\n'); | |
| const lineIndex = lines.findIndex((line) => line.match(anchor)); | |
| // add after given line | |
| lines.splice(lineIndex + offset, 0, newLine); | |
| return lines.join('\n'); | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source https://github.com/hyochan/react-native-iap/blob/b7aa8fa6d5c303bfcdae3cd75b1299280b211d9d/plugin/src/withIAP.ts#L36-L47