Skip to content

Commit

Permalink
Default to empty smithy classpath config
Browse files Browse the repository at this point in the history
  • Loading branch information
daddykotex committed Dec 30, 2023
1 parent 0414f7b commit 8430efc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions modules/backend/src/main/scala/smithy4s_codegen/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ final class InvalidConfiguration(message: String)
final case class SmithyClasspathConfig(
entries: Map[String, FPath]
)
object SmithyClasspathConfig {
val Empty: SmithyClasspathConfig = SmithyClasspathConfig(Map.empty)
}

private final case class JsonSmithyClasspathConfig(
entries: Map[String, String]
Expand Down Expand Up @@ -56,17 +59,15 @@ object Config {
asFPath(jar).tupleLeft(dep)
}
.map(_.toMap)
.map(SmithyClasspathConfig)
.map(SmithyClasspathConfig.apply)
}
}

val smithyClasspathConfigFile =
val smithyClasspathConfig =
env("SMITHY_CLASSPATH_CONFIG")
.default("./smithy-classpath.json")
.evalMap { asFPath }

val smithyClasspathConfig = smithyClasspathConfigFile
.evalMap { loadSmithyClasspathConfig }
.evalMap { p => asFPath(p).flatMap(loadSmithyClasspathConfig) }
.option
.map(_.getOrElse(SmithyClasspathConfig.Empty))

val config = smithyClasspathConfig.map(Config.apply)

Expand Down

0 comments on commit 8430efc

Please sign in to comment.