From 9eb575252f15a6c7ce028b23a4de03ae56f573ec Mon Sep 17 00:00:00 2001 From: David Howell Date: Wed, 15 Feb 2017 22:05:20 +1030 Subject: [PATCH] Replace `npm run get-version` with JSON parser gradle function (#849) * Replace npm run get-version with JSON parser from groovy --- react-native/android/publish_android_template | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/react-native/android/publish_android_template b/react-native/android/publish_android_template index 16556063..6118b1fd 100644 --- a/react-native/android/publish_android_template +++ b/react-native/android/publish_android_template @@ -66,9 +66,17 @@ String getAppId () { apply from: 'analytics.gradle' +import groovy.json.JsonSlurper + +def getNpmVersion() { + def inputFile = new File(buildscript.sourceFile.getParent() + "/../package.json") + def packageJson = new JsonSlurper().parseText(inputFile.text) + return packageJson["version"] +} + task send(type: SendAnalyticsTask) { applicationId = getAppId() - version = "npm --silent run get-version".execute(null, projectDir).text.trim() + version = getNpmVersion().trim() } preBuild.dependsOn send