Skip to content

Commit

Permalink
Merge pull request arnesson#905 from arnesson/fix-after-prepare
Browse files Browse the repository at this point in the history
refactor after_prepare hook
  • Loading branch information
soumak77 authored Oct 10, 2018
2 parents dc2ce2c + cac4c2b commit 52a0c4a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 44 deletions.
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ xmlns:android="http://schemas.android.com/apk/res/android">
</engines>

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

Expand Down Expand Up @@ -64,7 +63,6 @@ xmlns:android="http://schemas.android.com/apk/res/android">
</platform>

<platform name="ios">
<hook type="after_prepare" src="scripts/ios/after_prepare.js" />
<hook type="after_plugin_install" src="scripts/ios/after_plugin_install.js" />
<hook type="before_plugin_uninstall" src="scripts/ios/before_plugin_uninstall.js" />

Expand Down Expand Up @@ -118,4 +116,6 @@ xmlns:android="http://schemas.android.com/apk/res/android">
<clobbers target="FirebasePlugin" />
</js-module>
</platform>

<hook type="after_prepare" src="scripts/after_prepare.js" />
</plugin>
23 changes: 21 additions & 2 deletions scripts/ios/after_prepare.js → scripts/after_prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
*/
var fs = require('fs');
var path = require('path');
var utilities = require("../lib/utilities");
var utilities = require("./lib/utilities");

var config = fs.readFileSync('config.xml').toString();
var name = utilities.getValue(config, 'name');

var IOS_DIR = 'platforms/ios';
var ANDROID_DIR = 'platforms/android';

var PLATFORM = {
IOS: {
Expand All @@ -27,13 +28,31 @@ var PLATFORM = {
IOS_DIR + '/www/GoogleService-Info.plist',
'www/GoogleService-Info.plist'
]
},
ANDROID: {
dest: [
ANDROID_DIR + '/google-services.json',
ANDROID_DIR + '/app/google-services.json'
],
src: [
'google-services.json',
ANDROID_DIR + '/assets/www/google-services.json',
'www/google-services.json',
ANDROID_DIR + '/app/src/main/google-services.json'
],
}
};

module.exports = function (context) {
//get platform from the context supplied by cordova
var platforms = context.opts.platforms;
// Copy key files to their platform specific folders
if (utilities.directoryExists(IOS_DIR)) {
if (platforms.indexOf('ios') !== -1 && utilities.directoryExists(IOS_DIR)) {
console.log('Preparing Firebase on iOS');
utilities.copyKey(PLATFORM.IOS);
}
if (platforms.indexOf('android') !== -1 && utilities.directoryExists(ANDROID_DIR)) {
console.log('Preparing Firebase on Android');
utilities.copyKey(PLATFORM.ANDROID);
}
};
39 changes: 0 additions & 39 deletions scripts/android/after_prepare.js

This file was deleted.

1 change: 0 additions & 1 deletion scripts/lib/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ fs.ensureDirSync = function (dir) {
};

module.exports = {

/**
* Used to get the name of the application as defined in the config.xml.
*
Expand Down

0 comments on commit 52a0c4a

Please sign in to comment.