[K/JS] Introduce the ability to consume platform-specific cli arguments inside the main function ^KT-16981 Fixed

This commit is contained in:
Artem Kobzar
2023-11-18 11:01:34 +00:00
committed by Space Team
parent ceded87a3a
commit 1832f5a3f7
15 changed files with 93 additions and 3 deletions
@@ -47,6 +47,24 @@ class Kotlin2JsIrGradlePluginIT : KGPBaseTest() {
}
}
@DisplayName("nodejs main function arguments")
@GradleTest
fun testNodeJsMainArguments(gradleVersion: GradleVersion) {
project("kotlin-js-nodejs-project", gradleVersion) {
buildGradle.appendText(
"""
|
|tasks.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec).configureEach {
| args += ["test", "'Hello, World'"]
|}
""".trimMargin()
)
build("nodeRun") {
assertOutputContains("ACCEPTED: test;'Hello, World'")
}
}
}
@DisplayName("stale output is cleaned")
@GradleTest
fun testCleanOutputWithEmptySources(gradleVersion: GradleVersion) {
@@ -17,6 +17,7 @@ kotlin {
useCommonJs()
binaries.executable()
nodejs {
passProcessArgvToMainFunction()
}
}
}
@@ -11,4 +11,8 @@ fun best(): Int {
fun simpleBest(): Int {
return 73
}
fun main(args: Array<String>) {
println("ACCEPTED: ${args.drop(2).joinToString(";")}")
}