MCPcopy
hub / github.com/ionic-team/capacitor / findPluginClasses

Function findPluginClasses

cli/src/util/iosplugin.ts:36–56  ·  view source on GitHub ↗
(files: string[])

Source from the content-addressed store, hash-verified

34}
35
36export async function findPluginClasses(files: string[]): Promise<string[]> {
37 const classList: string[] = [];
38
39 for (const file of files) {
40 const fileData = readFileSync(file, 'utf-8');
41 const swiftPluginRegex = RegExp(/@objc\(([A-Za-z0-9_-]+)\)/);
42 const objcPluginRegex = RegExp(/CAP_PLUGIN\(([A-Za-z0-9_-]+)/);
43
44 const swiftMatches = swiftPluginRegex.exec(fileData);
45 if (swiftMatches?.[1] && !classList.includes(swiftMatches[1])) {
46 classList.push(swiftMatches[1]);
47 }
48
49 const objcMatches = objcPluginRegex.exec(fileData);
50 if (objcMatches?.[1] && !classList.includes(objcMatches[1])) {
51 classList.push(objcMatches[1]);
52 }
53 }
54
55 return classList;
56}
57
58export async function writePluginJSON(config: Config, classList: string[]): Promise<void> {
59 const capJSONFile = resolve(config.ios.nativeTargetDirAbs, 'capacitor.config.json');

Callers 1

generateIOSPackageJSONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected