[K/JS] Introduce the ability to consume platform-specific cli arguments inside the main function ^KT-16981 Fixed
This commit is contained in:
+18
@@ -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) {
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ kotlin {
|
||||
useCommonJs()
|
||||
binaries.executable()
|
||||
nodejs {
|
||||
passProcessArgvToMainFunction()
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -11,4 +11,8 @@ fun best(): Int {
|
||||
|
||||
fun simpleBest(): Int {
|
||||
return 73
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println("ACCEPTED: ${args.drop(2).joinToString(";")}")
|
||||
}
|
||||
Reference in New Issue
Block a user