Hi :slightly_smiling_face: Would it be possible to...
# konsist
r
Hi 🙂 Would it be possible to create a scope of all modules ending with, eg. "-ui"?
Copy code
fun KoScope.withinModules(
    moduleSuffixes: List<String> = emptyList(),
    sourceSetName: String? = null
): KoScope {
    val pathPrefixes = moduleSuffixes.map { moduleSuffix ->
        val pathPrefix = "$projectRootPath.*$moduleSuffix"
        if (sourceSetName != null) {
            "$pathPrefix/src/$sourceSetName/.*"
        } else {
            "$pathPrefix/src/.*"
        }.toMacOsSeparator()
    }

    return KoScopeCore(
        files.filter {
            pathPrefixes.map { pathPrefix ->
                Regex(pathPrefix)
            }.any { pathPrefix ->
                it.path.toMacOsSeparator().matches(pathPrefix)
            }
        }
    )
}
I have created this function that seems to work.
👍 1