1.6 KiB
1.6 KiB
How I can run a npx Gradle task with Kotlin/JS?
I have a project that includes some dependencies downloaded from NPM and source code in Typescript.
I want to use TypeScriptToLua to convert my Typescript files into Lua.
I see that Kotlin/JS has two
fun useTool(
exec: ExecSpec,
tool: String,
nodeArgs: List<String> = listOf(),
args: List<String>
) {
exec.workingDir = dir
exec.executable = nodeExecutable
exec.args = nodeArgs + require(tool) + args
}
npmProject.useTool(
exec,
"dukat/bin/dukat-cli.js",
listOf(),
args
)
In build.gradle.kts I've configured the Kotlin Multiplatform plugin to download
the typescript-to-lua dependency
plugins {
kotlin("multiplatform")
}
kotlin {
js(IR) {
browser()
}
sourceSets {
val jsMain: KotlinSourceSet by getting {
dependencies {
implementation(npm("typescript-to-lua", "1.1.1"))
}
}
}
}
and this correctly downloads the NPM module binaries:
build/js/packages/data-model/node_modules/.bin/tstl