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

Function resolvePlugin

cli/src/plugin.ts:63–99  ·  view source on GitHub ↗
(config: Config, name: string)

Source from the content-addressed store, hash-verified

61}
62
63export async function resolvePlugin(config: Config, name: string): Promise<Plugin | null> {
64 try {
65 const packagePath = resolveNode(config.app.rootDir, name, 'package.json');
66 if (!packagePath) {
67 fatal(`Unable to find ${c.strong(`node_modules/${name}`)}.\n` + `Are you sure ${c.strong(name)} is installed?`);
68 }
69
70 const rootPath = dirname(packagePath);
71 const meta = await readJSON(packagePath);
72 if (!meta) {
73 return null;
74 }
75 if (meta.capacitor) {
76 return {
77 id: name,
78 name: fixName(name),
79 version: meta.version,
80 rootPath,
81 repository: meta.repository,
82 manifest: meta.capacitor,
83 };
84 }
85 const pluginXMLPath = join(rootPath, 'plugin.xml');
86 const xmlMeta = await readXML(pluginXMLPath);
87 return {
88 id: name,
89 name: fixName(name),
90 version: meta.version,
91 rootPath: rootPath,
92 repository: meta.repository,
93 xml: xmlMeta.plugin,
94 };
95 } catch (e) {
96 // ignore
97 }
98 return null;
99}
100
101export function getDependencies(config: Config): string[] {
102 return [

Callers 2

buildDependencyTextsFunction · 0.90
getPluginsFunction · 0.70

Calls 5

resolveNodeFunction · 0.90
fatalFunction · 0.90
readXMLFunction · 0.90
readJSONFunction · 0.85
fixNameFunction · 0.85

Tested by

no test coverage detected