Created
December 11, 2018 14:27
-
-
Save hypest/ceaf20a8e7d9b8404e4a5ff2e6c36650 to your computer and use it in GitHub Desktop.
Gradle util to extract a GitHub based dependency's hash from package.json
This file contains hidden or 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
import groovy.json.JsonSlurper | |
def readHashedVersion(packagejson, packageName, section) { | |
def packageSlurper = new JsonSlurper() | |
def packageJson = packageSlurper.parse file(packagejson) | |
def dep = packageJson.get(section).get(packageName) | |
def hash = dep.substring(dep.lastIndexOf('#') + 1) | |
return hash; | |
} | |
ext { | |
readHashedVersion = this.&readHashedVersion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment