Last active
November 6, 2016 06:46
-
-
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 π
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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