Permalink
Browse files

Node gradle task updates for custom projects

  • Loading branch information...
richturner committed Nov 25, 2017
1 parent b6c21bd commit 0f5c7851b1383aed511b624a2c7a43d610599155
Showing with 11 additions and 9 deletions.
  1. +11 −9 project.gradle
View
@@ -59,39 +59,41 @@ node {
version = "8.9.0"
workDir = file("${rootDir}/.node")
}
def nodeDir = {
ext.nodeDir = {
def osName = com.moowork.gradle.node.util.PlatformHelper.INSTANCE.getOsName()
def osArch = com.moowork.gradle.node.util.PlatformHelper.INSTANCE.getOsArch()
def version = node.version
node.workDir.absolutePath + File.separator + "node-v${version}-${osName}-${osArch}"
}
def nodeModuleDir = {
ext.nodeModuleDir = {
isFamily(FAMILY_WINDOWS) ? "${nodeDir()}/node_modules" : "${nodeDir()}/lib/node_modules"
}
def nodeModuleGlobal = {
file("${nodeModuleDir()}/${it}/bin/${it}")
ext.nodeModuleGlobal = {
dir, mod ->
file("${nodeModuleDir()}/${dir}/bin/${mod}")
}
def nodeModuleLocal = {
file("${projectDir}/node_modules/${it}/bin/${it}")
ext.nodeModuleLocal = {
dir, mod ->
file("${projectDir}/node_modules/${dir}/bin/${mod}")
}
// Add bower tasks
task bowerInstall(type: NpmTask) {
dependsOn nodeSetup
args = ['install', '-g', 'bower']
outputs.upToDateWhen {
nodeModuleGlobal('bower').exists()
nodeModuleGlobal('bower', 'bower').exists()
}
}
task bowerUpdate(type: NodeTask) {
dependsOn bowerInstall
script = nodeModuleGlobal('bower')
script = nodeModuleGlobal('bower', 'bower')
args = ['update']
inputs.file("${project.projectDir}/bower.json")
}
task bowerPrune(type: NodeTask) {
dependsOn bowerInstall
script = nodeModuleGlobal('bower')
script = nodeModuleGlobal('bower', 'bower')
args = ['prune']
inputs.file("${project.projectDir}/bower.json")
}

0 comments on commit 0f5c785

Please sign in to comment.