File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
main/kotlin/com/github/gradle/node
test/groovy/com/github/gradle/node Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import com.github.gradle.node.yarn.task.YarnSetupTask
1313import com.github.gradle.node.yarn.task.YarnTask
1414import org.gradle.api.Plugin
1515import org.gradle.api.Project
16+ import org.gradle.kotlin.dsl.create
1617import org.gradle.kotlin.dsl.named
1718import org.gradle.kotlin.dsl.register
1819import java.io.File
@@ -59,7 +60,7 @@ class NodePlugin : Plugin<Project> {
5960 project.tasks.addRule(" Pattern: \" npm_<command>\" : Executes an NPM command." ) {
6061 val taskName = this
6162 if (taskName.startsWith(" npm_" )) {
62- project.tasks.register <NpmTask >(taskName) {
63+ project.tasks.create <NpmTask >(taskName) {
6364 val tokens = taskName.split(" _" ).drop(1 ) // all except first
6465 npmCommand.set(tokens)
6566 if (tokens.first().equals(" run" , ignoreCase = true )) {
@@ -74,7 +75,7 @@ class NodePlugin : Plugin<Project> {
7475 project.tasks.addRule(" Pattern: \" yarn_<command>\" : Executes an Yarn command." ) {
7576 val taskName = this
7677 if (taskName.startsWith(" yarn_" )) {
77- project.tasks.register <YarnTask >(taskName).configure {
78+ project.tasks.create <YarnTask >(taskName) {
7879 val tokens = taskName.split(" _" ).drop(1 ) // all except first
7980 yarnCommand.set(tokens)
8081 if (tokens.first().equals(" run" , ignoreCase = true )) {
Original file line number Diff line number Diff line change @@ -22,6 +22,26 @@ class NpmRule_integTest extends AbstractIntegTest {
2222 result. outcome == TaskOutcome . SUCCESS
2323 }
2424
25+ def ' can configure npm_ rule task' () {
26+ given :
27+ writeBuild('''
28+ plugins {
29+ id 'com.github.node-gradle.node'
30+ }
31+
32+ npm_run_build {
33+ doFirst { project.logger.info('configured') }
34+ }
35+ ''' )
36+ writeEmptyPackageJson()
37+
38+ when :
39+ def result = buildTask(' help' )
40+
41+ then :
42+ result. outcome == TaskOutcome . SUCCESS
43+ }
44+
2545 def ' can execute an npm module using npm_run_' () {
2646 given :
2747 writeBuild('''
Original file line number Diff line number Diff line change @@ -42,4 +42,25 @@ class YarnRule_integTest extends AbstractIntegTest {
4242 result. task(" :yarn_run_hello" ). outcome == TaskOutcome . SUCCESS
4343 result. output. contains(" Hello world!" )
4444 }
45+
46+ def ' can configure yarn_ rule task' () {
47+ given :
48+ writeBuild("""
49+ plugins {
50+ id 'com.github.node-gradle.node'
51+ }
52+
53+ yarn_run_build {
54+ doFirst { project.logger.info('configured') }
55+ }
56+ """ )
57+
58+ copyResources(" fixtures/yarn-rule/package.json" , " package.json" )
59+
60+ when :
61+ def result = buildTask(" help" )
62+
63+ then :
64+ result. outcome == TaskOutcome . SUCCESS
65+ }
4566}
You can’t perform that action at this time.
0 commit comments