Skip to content

Instantly share code, notes, and snippets.

@hypest
Created December 11, 2018 14:27
Show Gist options
  • Save hypest/ceaf20a8e7d9b8404e4a5ff2e6c36650 to your computer and use it in GitHub Desktop.
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
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