diff --git a/spec/PluginInfo/PluginInfo.spec.js b/spec/PluginInfo/PluginInfo.spec.js index 1aaca7f2..78589a19 100644 --- a/spec/PluginInfo/PluginInfo.spec.js +++ b/spec/PluginInfo/PluginInfo.spec.js @@ -182,6 +182,23 @@ describe('PluginInfo', function () { }); }); + it('Test 005: read podspec', function () { + const p = new PluginInfo(path.join(pluginsDir, 'org.test.plugins.withcocoapods')); + const result = p.getPodSpecs('ios'); + expect(result.length).toBe(1); + const podSpec = result[0]; + expect(Object.keys(podSpec.declarations).length).toBe(2); + expect(Object.keys(podSpec.sources).length).toBe(1); + expect(Object.keys(podSpec.libraries).length).toBe(4); + expect(Object.keys(podSpec.plugins).length).toBe(2); + expect(podSpec.declarations['use-frameworks']).toBe('true'); + expect(podSpec.sources['https://github.com/CocoaPods/Specs.git'].source).toBe('https://github.com/CocoaPods/Specs.git'); + expect(podSpec.libraries.AFNetworking.spec).toBe('~> 3.2'); + expect(podSpec.libraries.Eureka['swift-version']).toBe('4.1'); + expect(podSpec.plugins['my-other-plugin'].name).toBe('my-other-plugin'); + expect(podSpec.plugins['cocoapods-art'].options).toBe(":sources => [ 'my.source.url' ]"); + }); + describe('Platform', () => { it('Test 019: platform supports xml passthrough', function () { const platforms = pluginPassthrough.getPlatforms(); diff --git a/spec/fixtures/plugins/org.test.plugins.withcocoapods/plugin.xml b/spec/fixtures/plugins/org.test.plugins.withcocoapods/plugin.xml index 2f6b6233..04a5c3de 100644 --- a/spec/fixtures/plugins/org.test.plugins.withcocoapods/plugin.xml +++ b/spec/fixtures/plugins/org.test.plugins.withcocoapods/plugin.xml @@ -44,6 +44,10 @@ + + + + diff --git a/src/PluginInfo/PluginInfo.js b/src/PluginInfo/PluginInfo.js index db43f115..296f45bf 100644 --- a/src/PluginInfo/PluginInfo.js +++ b/src/PluginInfo/PluginInfo.js @@ -278,6 +278,10 @@ class PluginInfo { * * * + * + * + * + * * * * @param {string} platform @@ -286,6 +290,7 @@ class PluginInfo { return this._getTagsInPlatform('podspec', platform).map(tag => { const config = tag.find('config'); const pods = tag.find('pods'); + const pluginsTag = tag.find('plugins'); const sources = config && config.findall('source') .map(el => ({ source: el.attrib.url })) @@ -297,7 +302,11 @@ class PluginInfo { .map(t => t.attrib) .reduce((acc, val) => Object.assign(acc, { [val.name]: val }), {}); - return { declarations, sources, libraries }; + const plugins = pluginsTag && pluginsTag.findall('plugin') + .map(t => t.attrib) + .reduce((acc, val) => Object.assign(acc, { [val.name]: val }), {}); + + return { declarations, sources, libraries, plugins }; }); }