Skip to content

Instantly share code, notes, and snippets.

@agu-z
Last active November 6, 2016 06:46
Show Gist options
  • Save agu-z/97b56cbe920790ce05d8bf3b8f6d2c00 to your computer and use it in GitHub Desktop.
Save agu-z/97b56cbe920790ce05d8bf3b8f6d2c00 to your computer and use it in GitHub Desktop.
Useful script that automates nativescript-plugin-firebase's setup. Add it to your `postinstall` script and enjoy πŸ˜‰
let fs = require('fs');
module.exports = function() {
let fileContent = fs.readFileSync('./platforms/android/build.gradle').toString();
if (!/(classpath "com.google.gms:google-services:.*")/.test(fileContent)) {
fileContent = fileContent.replace(/(classpath "com.android.tools.build:gradle:.*")/,
'$1\n\t\tclasspath "com.google.gms:google-services:3.0.0"');
}
if (!/apply plugin: "com.google.gms.google-services"/.test(fileContent)) {
fileContent = fileContent + '\n' + 'apply plugin: "com.google.gms.google-services"';
}
fs.writeFileSync('./platforms/android/build.gradle', fileContent);
};
if (!module.parent) {
module.exports();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment