Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#294 Explicitly cast workingDir as a java.io.File object in afterEvaluate(). #295

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/groovy/com/moowork/gradle/node/npm/NpmTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ class NpmTask
}
}

void afterEvaluate(nodeModulesDir) {
void afterEvaluate(nodeModulesDir)
{
if ( !this.runner.workingDir )
{
setWorkingDir( nodeModulesDir )
}

if ( !this.runner.workingDir.exists() )
if ( ! ((this.runner.workingDir) as File).exists() )
{
this.runner.workingDir.mkdirs();
((this.runner.workingDir) as File).mkdirs()
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/test/groovy/com/moowork/gradle/node/npm/NpmTaskTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,23 @@ class NpmTaskTest
task.result.exitValue == 0
1 * this.execSpec.setIgnoreExitValue( false )
}

def "exec npm task (set workingDir String)"()
{
given:
this.props.setProperty( 'os.name', 'Linux' )
this.execSpec = Mock( ExecSpec )

def task = this.project.tasks.create( 'simple', NpmTask )
task.workingDir = 'testDir'

when:
this.project.evaluate()
task.exec()

then:
task.result.exitValue == 0
1 * this.execSpec.setWorkingDir( 'testDir' )
}

}