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

Added support for the NODE_PATH environment variable #22

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
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ ext.compatibilityVersion = '1.6'
sourceCompatibility = compatibilityVersion
targetCompatibility = compatibilityVersion

uploadArchives {
repositories {
mavenDeployer {
repository(url: 'http://imdev.nscorp.com/nexus/content/repositories/releases') {
authentication(userName: publishUser, password: publishPassword)
}
snapshotRepository(url: 'http://imdev.nscorp.com/nexus/content/repositories/snapshots') {
authentication(userName: publishUser, password: publishPassword)
}
}
}
}

repositories {
jcenter()
}
Expand Down
32 changes: 25 additions & 7 deletions src/main/groovy/com/moowork/gradle/gulp/GulpTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.gradle.api.GradleException
class GulpTask
extends NodeTask
{
private final static String GULP_SCRIPT = 'node_modules/gulp/bin/gulp.js';
private final static String GULP_SCRIPT = 'gulp/bin/gulp.js';

public GulpTask()
{
Expand All @@ -16,12 +16,7 @@ class GulpTask
@Override
void exec()
{
def localGulp = this.project.file( new File( this.project.node.nodeModulesDir, GULP_SCRIPT ) )
if ( !localGulp.isFile() )
{
throw new GradleException(
"gulp not installed in node_modules, please first run 'gradle ${GulpPlugin.GULP_INSTALL_NAME}'" )
}
def localGulp = this.project.file( getSourceFile() )

// If colors are disabled, add --no-color to args
if ( !this.project.gulp.colors ) {
Expand Down Expand Up @@ -55,4 +50,27 @@ class GulpTask
}
}
}

private File getSourceFile() {
//Local node_module instance
def gulpScript = new File( this.project.node.nodeModulesDir, 'node_modules/' + GULP_SCRIPT )
println "testing " + gulpScript
if (gulpScript.isFile()) {
return gulpScript
}

def env = System.getenv()
String globalNodePath = env['NODE_PATH']
def directories = globalNodePath?.tokenize(File.pathSeparatorChar)
for (String directory : directories) {
gulpScript = new File( directory, GULP_SCRIPT )
println "testing " + gulpScript
if (gulpScript.isFile()) {
return gulpScript
}
}

throw new GradleException(
"gulp not installed in node_modules, please first run 'gradle ${GulpPlugin.GULP_INSTALL_NAME}'" )
}
}
2 changes: 2 additions & 0 deletions src/test/groovy/com/moowork/gradle/gulp/GulpTaskTest.groovy
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.moowork.gradle.gulp

import org.gradle.api.GradleException
import spock.lang.IgnoreIf

class GulpTaskTest
extends AbstractTaskTest
{
@IgnoreIf({env['NODE_PATH']})
def "gulp not installed"()
{
given:
Expand Down