podshim
v1.0.1
Published
Provides utility functions to shim the Podfile of a React Native application programatically.
Downloads
6
Readme
What is PodShim?
PodShim allows you to programatically add Pods to a Podfile.
Warning
You should not manipulate the Podfile flippantly, do not accept user input as it could result in Podfile injection. Static, safe, and tested changes are key to making this an effective solution.
Usage
Creating Pod Reference
import { pod } from "podshim";
// pod 'PodName'
console.log(
pod({
name: "PodName",
})
);
// pod 'PodName', '>= 0.2'
console.log(
pod({
name: "PodName",
version: ">= 0.2",
})
);
// pod 'PodName', :git => 'https://github.com/PodName/PodName.git'
console.log(
pod({
name: "PodName",
git: "https://github.com/PodName/PodName.git",
})
);
Shimming Podfile Contents
import { readFileSync, writeFileSync } from "fs";
import { pod, shim } from "podshim";
/**
* Will add the pod reference above the line that contains
* the 'use_framework' string.
*/
const contents = readFileSync("./Podfile", "utf-8");
const modified = shim({
contents,
anchor: "use_frameworks",
insert: [
pod({ name: "Podname" })
]
});
writeFileSync("./Podfile", "utf-8");