srs / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
866 stars 211 forks source link

NPX? #312

Open Exerosis opened 5 years ago

Exerosis commented 5 years ago

I might be missing something obvious, but how I can create a gradle task that runs npx it gets mad about the missing script property if I just omit that, but IDK what I would put there if I just wanted to execute npx.

bennyboer commented 5 years ago

Hi there!

It does not seem like this project is still active at the moment.

For a workaround you might use something like this:

task npxWorkaround(type: Exec) {
  dependsOn "npmInstall"

  if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")) {
    commandLine "${dirWhereIInstalledNodeModules}/node_modules/.bin/my_module_executable.cmd"
  } else {
    commandLine "${dirWhereIInstalledNodeModules}/node_modules/.bin/my_module_executable"
  }
}

If you do not have node installed locally and install it via the plugin you might need to actually call it directly via a NodeTask.

task doSth(type: NodeTask) {
  dependsOn "npmInstall"

  script = file("${dirWhereIInstalledNodeModules}/node_modules/my_module/bin/my_module_executable")
}
Exerosis commented 5 years ago

Ah, this seems like a good solution! Let me give this a go, thank you so much for taking the time to give me a hand here.

deepy commented 4 years ago

There's support for NpxTask in the fork thanks to this PR https://github.com/node-gradle/gradle-node-plugin/pull/32