Skip to content

Commit

Permalink
Use npm install for dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ProTip committed Jun 5, 2020
1 parent cc420e5 commit 9ef13c1
Showing 1 changed file with 11 additions and 44 deletions.
55 changes: 11 additions & 44 deletions vue-build.gradle
Original file line number Diff line number Diff line change
@@ -1,42 +1,5 @@
ext.spaBuildDir = "$buildDir/spa"

task npmCI(type: NpmTask, group: 'Node') {
dependsOn 'npmCISwitch'

enabled = false

inputs.file(file("${projectDir}/package.json"))
inputs.file(file("${projectDir}/package-lock.json"))

outputs.dir(file("${projectDir}/node_modules"))

args = ['ci']
}

task npmCISwitch {
inputs.file(file("${projectDir}/package.json"))
inputs.file(file("${projectDir}/package-lock.json"))
inputs.dir "src"
if(file("build").isDirectory()){
inputs.dir "build"
}
if(file("config").isDirectory()) {
inputs.dir "config"
}

outputs.file "${buildDir}/switch"

outputs.cacheIf {true}
doLast {
tasks.npmCI.enabled = true
}
}
gradle.taskGraph.whenReady { taskGraph ->
def groups = taskGraph.getAllTasks().collect { it.group }
if (groups.contains('test'))
tasks.npmCI.enabled = true
}

task runNpmBuild(type: NpmTask, group: 'build') {
inputs.file 'package.json'
inputs.file 'package-lock.json'
Expand All @@ -45,24 +8,28 @@ task runNpmBuild(type: NpmTask, group: 'build') {
outputs.dir(file("$spaBuildDir"))
outputs.cacheIf { true }

args = ['run', 'build:ci']
def npmCommand = System.env.CI ?
'ci:build' :
'dev:build'

args = ['run', npmCommand]
}
assemble.dependsOn runNpmBuild

task runNpmTest(type: NpmTask, group: 'test') {
dependsOn npmCI

inputs.file 'package.json'
inputs.file 'package-lock.json'
if(file("build").isDirectory()){
inputs.dir "build"
}

if(file("config").isDirectory()) {
inputs.dir "config"
}
inputs.dir 'src'

args = ['run', 'test:unit']
def npmCommand = System.env.CI ?
'ci:test' :
'dev:test'

args = ['run', 'ci:test:unit']
}
check.dependsOn runNpmTest

Expand Down

0 comments on commit 9ef13c1

Please sign in to comment.