Skip to content

Commit

Permalink
after_prepare hook to be outside the platform element in plugin.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
ippeiukai committed Dec 4, 2017
1 parent 4aef447 commit 84d306e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
11 changes: 2 additions & 9 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
<engine name="cordova" version=">=6.0.0"/>
</engines>

<platform name="ios">
<hook src="scripts/create_ios_strings.js" type="after_prepare" />
</platform>
<hook src="scripts/create_strings.js" type="after_prepare" />

<platform name="android">
<hook src="scripts/create_android_strings.js" type="after_prepare" />
</platform>


</plugin>
</plugin>
22 changes: 22 additions & 0 deletions scripts/create_strings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var ios_script = require('./create_ios_strings');
var android_script = require('./create_android_strings');

module.exports = function(context) {
var Q = context.requireCordovaModule('q')
var platformMetadata = context.requireCordovaModule('cordova-lib/src/cordova/platform_metadata');

return platformMetadata.getPlatformVersions(context.opts.projectRoot)
.then(function(platformVersions) {
var promises = [];
var platforms = platformVersions.map(function(platformVersion) {
return platformVersion.platform;
});
if (platforms.indexOf('ios') >= 0) {
promises.push(ios_script(context));
}
if (platforms.indexOf('android') >= 0) {
promises.push(android_script(context));
}
return Q.all(promises);
});
}

0 comments on commit 84d306e

Please sign in to comment.