Skip to content

NpmExecTask

Summary

Basic task for executing various npm commands. Extends NodeExecTask and provides access to npm executable.

The task can be created and configured in a build.gradle.kts file by registering it with correct type.

build.gradle.kts
1
2
3
4
5
tasks {
  register("name", dev.petuska.npm.publish.task.NpmExecTask::class) {
    ...
  }
}

Properties

Property Type Default When Kotlin plugin is present
npm RegularFileProperty $nodeHome/bin/npm
Property CLI System/Gradle Environment
build.gradle.kts
1
2
3
4
5
6
7
8
9
tasks {
  register("name", dev.petuska.npm.publish.task.NpmExecTask::class) {
    npm.set(layout.projectDirectory.dir("/usr/share/node/bin/npm"))
    doLast {
      val args = listOf("--help")
      npmExec(args)
    }
  }
}

npm

Direct npm executable.