Skip to content

Instantly share code, notes, and snippets.

@yawarsohail
Last active July 12, 2017 13:38
Show Gist options
  • Save yawarsohail/1b2998d5cd860e01193cec86f6329223 to your computer and use it in GitHub Desktop.
Save yawarsohail/1b2998d5cd860e01193cec86f6329223 to your computer and use it in GitHub Desktop.
Cordova Hook for adding keystore file when android platform is added.
#!/usr/bin/env node
// This hook will copy keystore and its properties file in android
// platform directory when ever android platform is added.
//
// Save hook under `project-root/scripts`
//
// Don't forget to install xml2js using npm if it is not already installed.
// `$ npm install xml2js`
// First generate keystore file using below tutorial.
// http://ionicframework.com/docs/v1/guide/publishing.html
// Save generated .keystore file in root directory.
// Create a new file in root directory "release-signing.properties" with below content
//
// key.store=<keystorefilename>.keystore
// key.store.password=<keystorepassword>
// key.alias=<aliasName>
// key.alias.password=<aliaspassword>
//
//
//
// Then add below line in android section.
// <platform name="android">
// <hook src="scripts/add_keystore_android.js" type="after_platform_add"/>
// ...
// </platform>
//
// Keystore filename should be same as yours in code.
//
// I am adding this for my self so that I can remember. And it may help others who wants to do same.
//
var fs = require('fs');
var xml2js = require('xml2js');
fs.createReadStream('release-signing.properties').pipe(fs.createWriteStream('platforms/android/release-signing.properties'));
fs.createReadStream('earlybird12.keystore').pipe(fs.createWriteStream('platforms/android/<keystorefilename>.keystore'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment