[Gradle, JS] Remove copypaste in js compiler argument
#KT-38485 fixed
This commit is contained in:
+6
@@ -15,6 +15,12 @@ enum class KotlinJsCompilerType {
|
|||||||
|
|
||||||
fun byArgumentOrNull(argument: String): KotlinJsCompilerType? =
|
fun byArgumentOrNull(argument: String): KotlinJsCompilerType? =
|
||||||
values().firstOrNull { it.name.equals(argument, ignoreCase = true) }
|
values().firstOrNull { it.name.equals(argument, ignoreCase = true) }
|
||||||
|
|
||||||
|
fun byArgument(argument: String): KotlinJsCompilerType =
|
||||||
|
byArgumentOrNull(argument)
|
||||||
|
?: throw IllegalArgumentException(
|
||||||
|
"Unable to find $argument setting. Use [${values().toList().joinToString()}]"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -166,10 +166,7 @@ open class KotlinJsProjectExtension :
|
|||||||
compiler: String,
|
compiler: String,
|
||||||
body: KotlinJsTargetDsl.() -> Unit = { }
|
body: KotlinJsTargetDsl.() -> Unit = { }
|
||||||
): KotlinJsTargetDsl = js(
|
): KotlinJsTargetDsl = js(
|
||||||
KotlinJsCompilerType.byArgumentOrNull(compiler)
|
KotlinJsCompilerType.byArgument(compiler),
|
||||||
?: throw IllegalArgumentException(
|
|
||||||
"Unable to find $compiler setting. Use [${KotlinJsCompilerType.values().toList().joinToString()}]"
|
|
||||||
),
|
|
||||||
body
|
body
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -31,10 +31,7 @@ interface KotlinTargetContainerWithJsPresetFunctions :
|
|||||||
configure: KotlinJsTargetDsl.() -> Unit = { }
|
configure: KotlinJsTargetDsl.() -> Unit = { }
|
||||||
) = js(
|
) = js(
|
||||||
name = name,
|
name = name,
|
||||||
compiler = KotlinJsCompilerType.byArgumentOrNull(compiler)
|
compiler = KotlinJsCompilerType.byArgument(compiler),
|
||||||
?: throw IllegalArgumentException(
|
|
||||||
"Unable to find $compiler setting. Use [${KotlinJsCompilerType.values().toList().joinToString()}]"
|
|
||||||
),
|
|
||||||
configure = configure
|
configure = configure
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user