fix findSpecConfigFromResource

merge-requests/1/merge
ansgarz 2 years ago
parent 894cfefa12
commit 5f956ab42c

@ -18,14 +18,14 @@ internal fun findSpecConfigFromFile(file: ConfigFileName? = null): Result<SpecCo
// provide default config // provide default config
writeSpecConfigToFile(filePath, SpecConfig(listOf(CommandSpec("echo just_for_demo", "just_for_demo")))) writeSpecConfigToFile(filePath, SpecConfig(listOf(CommandSpec("echo just_for_demo", "just_for_demo"))))
} }
readFromFile(filePath).yamlToType() readFromFile(filePath).yamlToType<SpecConfig>()
} }
internal fun findSpecConfigFromResource(resourcePath: String): Result<SpecConfig> = runCatching { internal fun findSpecConfigFromResource(resourcePath: String): Result<SpecConfig> = runCatching {
val resource = Thread.currentThread().contextClassLoader.getResource(resourcePath) val resource = Thread.currentThread().contextClassLoader.getResource(resourcePath)
requireNotNull(resource) { "Resource $resourcePath not found" } requireNotNull(resource) { "Resource $resourcePath not found" }
return resource.readText().yamlToType() resource.readText().yamlToType()
} }

Loading…
Cancel
Save