gradle-node-plugin
gradle-node-plugin copied to clipboard
Cannot run NpxTask with different package name since 3.0.0
Npx has the feature to call a command from a package whose name differs from the command.
This can be achieved with the npx flag --package as seen on https://www.npmjs.com/package/npx
Before 3.0.0 I accessed the runner property of the NpxTask to set the argument;
@Suppress("UNCHECKED_CAST")
(runner.arguments as MutableList<Any>).addAll(
listOf(
"--package",
npxPackage
)
)
Since the 3.0.0 release, the runner property of the NpxTask is not available anymore
Could you implement this feature into the task or show me a way to set this argument again?
There's a getArgs() you can use instead
As I understand, that method only sets args for the command, not npx itself
hmm, I'll have to think a little bit about that, but in the meantime a not-so-pretty-workaround is to set --package as command and args.addAll(npxPackage) the way that it's done is that the full command is added by taking command and then adding args: https://github.com/node-gradle/gradle-node-plugin/blob/1d9259d/src/main/kotlin/com/github/gradle/node/npm/task/NpxTask.kt#L67-L68
Nice, that workaround works!
The workaround suggested by deepy works but it would be nice if we could add support of this correctly by adding a packageName optional property for instance. I did not know about this option when I started working on this NpxTask.