[Gradle, JS] Remove copypaste in js compiler argument

#KT-38485 fixed
This commit is contained in:
Ilya Goncharov
2020-04-22 12:16:04 +03:00
parent 8e282e8aad
commit ac11bc6710
3 changed files with 8 additions and 8 deletions
@@ -15,6 +15,12 @@ enum class KotlinJsCompilerType {
fun byArgumentOrNull(argument: String): KotlinJsCompilerType? =
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()}]"
)
}
}
@@ -166,10 +166,7 @@ open class KotlinJsProjectExtension :
compiler: String,
body: KotlinJsTargetDsl.() -> Unit = { }
): KotlinJsTargetDsl = js(
KotlinJsCompilerType.byArgumentOrNull(compiler)
?: throw IllegalArgumentException(
"Unable to find $compiler setting. Use [${KotlinJsCompilerType.values().toList().joinToString()}]"
),
KotlinJsCompilerType.byArgument(compiler),
body
)
@@ -31,10 +31,7 @@ interface KotlinTargetContainerWithJsPresetFunctions :
configure: KotlinJsTargetDsl.() -> Unit = { }
) = js(
name = name,
compiler = KotlinJsCompilerType.byArgumentOrNull(compiler)
?: throw IllegalArgumentException(
"Unable to find $compiler setting. Use [${KotlinJsCompilerType.values().toList().joinToString()}]"
),
compiler = KotlinJsCompilerType.byArgument(compiler),
configure = configure
)