Skip to content

Commit

Permalink
Make asset files map available for reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
eyedol committed Jul 2, 2024
1 parent f1e0c9c commit 2466c5d
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import org.webjars.WebJarVersionLocator
import java.io.File

class WebAssets private constructor(private val webJarVersionLocator: WebJarVersionLocator) {
private val materializeCss = "materializecss"
private val materialIcons = "material-design-icons"
private val webJarResource = "resources"

val assets = assetPathsMap.entries.flatMap {
assets -> assets.value.map { it.substringAfterLast("/") }
}

fun writeToRoborazziReportsDir(reportDir: File) {
writeLocalAssetsToRoborazziReportsDir(reportDir)
writeWebJarAssetsToRoborazziReportsDir(reportDir)
Expand All @@ -22,16 +24,7 @@ class WebAssets private constructor(private val webJarVersionLocator: WebJarVers
}

private fun writeWebJarAssetsToRoborazziReportsDir(reportDir: File) {
mapOf(
materializeCss to listOf(
"css/materialize.min.css",
"js/materialize.min.js",
),
materialIcons to listOf(
"material-icons.css",
"MaterialIcons-Regular.ttf",
)
).forEach { (key, value) ->
assetPathsMap.forEach { (key, value) ->
value.forEach { exactPath ->
webJarVersionLocator.locate(key, exactPath)?.let {
writeAssets(
Expand Down Expand Up @@ -71,6 +64,17 @@ class WebAssets private constructor(private val webJarVersionLocator: WebJarVers

companion object {

val assetPathsMap = mapOf(
"materializecss" to listOf(
"css/materialize.min.css",
"js/materialize.min.js",
),
"material-design-icons" to listOf(
"material-icons.css",
"MaterialIcons-Regular.ttf",
)
)

fun create(
webJarVersionLocator: WebJarVersionLocator = WebJarVersionLocator()
): WebAssets = WebAssets(webJarVersionLocator)
Expand Down

0 comments on commit 2466c5d

Please sign in to comment.