Skip to content

Instantly share code, notes, and snippets.

@micaiah-effiong
Created November 8, 2024 21:30
Show Gist options
  • Select an option

  • Save micaiah-effiong/88de9bf674a76fbc9393148b4ba658ab to your computer and use it in GitHub Desktop.

Select an option

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
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');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment