Skip to content

Commit

Permalink
Fix so that new args can be added for npmSetup and yarnSetup (fixes #226
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Sten Roger Sandvik committed Jun 14, 2017
1 parent fbdc0da commit ec89c78
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class NpmInstallTask
{
public final static String NAME = 'npmInstall'

public NpmInstallTask()
NpmInstallTask()
{
this.group = 'Node'
this.description = 'Install node packages from package.json.'
Expand Down
22 changes: 14 additions & 8 deletions src/main/groovy/com/moowork/gradle/node/npm/NpmSetupTask.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.moowork.gradle.node.npm

import com.moowork.gradle.node.task.SetupTask
import com.moowork.gradle.node.NodeExtension
import com.moowork.gradle.node.task.SetupTask
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
Expand All @@ -19,11 +19,11 @@ class NpmSetupTask

private NodeExtension config

protected Iterable<?> args = []
protected List<?> args = []

private ExecResult result

public NpmSetupTask()
NpmSetupTask()
{
dependsOn( SetupTask.NAME )

Expand All @@ -33,7 +33,7 @@ class NpmSetupTask
}

@Input
public Set<String> getInput()
Set<String> getInput()
{
def set = new HashSet<>()
set.add( getConfig().download )
Expand All @@ -43,7 +43,7 @@ class NpmSetupTask
}

@OutputDirectory
public File getNpmDir()
File getNpmDir()
{
return getVariant().npmDir
}
Expand All @@ -57,7 +57,7 @@ class NpmSetupTask
@Internal
protected getConfig()
{
if ( this.config != null)
if ( this.config != null )
{
return this.config
}
Expand All @@ -72,14 +72,20 @@ class NpmSetupTask
return getConfig().variant
}

List<?> getArgs()
{
return this.args
}

@Internal
void setArgs( final Iterable<?> value )
{
this.args = value
this.args = value.toList()
}

@TaskAction
void exec() {
void exec()
{
def runner = new NpmExecRunner( this.project )
runner.arguments.addAll( this.args )

Expand Down
8 changes: 4 additions & 4 deletions src/main/groovy/com/moowork/gradle/node/npm/NpmTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class NpmTask
{
protected NpmExecRunner runner

private Iterable<?> args = []
private List<?> args = []

private ExecResult result

private String[] npmCommand

public NpmTask()
NpmTask()
{
this.runner = new NpmExecRunner( this.project )
dependsOn( NpmSetupTask.NAME )
Expand All @@ -37,7 +37,7 @@ class NpmTask

void setArgs( final Iterable<?> value )
{
this.args = value
this.args = value.asList()
}

void setNpmCommand( String[] cmd )
Expand All @@ -46,7 +46,7 @@ class NpmTask
}

@Internal
Iterable<?> getArgs()
List<?> getArgs()
{
return this.args
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.moowork.gradle.node.yarn

import com.moowork.gradle.node.npm.NpmSetupTask
import com.moowork.gradle.node.npm.NpmTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputDirectory

Expand All @@ -13,7 +12,7 @@ class YarnSetupTask
{
public final static String NAME = 'yarnSetup'

public YarnSetupTask()
YarnSetupTask()
{
this.group = 'Node'
this.description = 'Setup a specific version of Yarn to be used by the build.'
Expand All @@ -22,7 +21,7 @@ class YarnSetupTask
}

@Input
public Set<String> getInput()
Set<String> getInput()
{
def set = new HashSet<>()
set.add( this.getConfig().download )
Expand All @@ -31,7 +30,7 @@ class YarnSetupTask
}

@OutputDirectory
public File getYarnDir()
File getYarnDir()
{
return this.getVariant().yarnDir
}
Expand Down

0 comments on commit ec89c78

Please # to comment.