mirror of
https://github.com/Instadapp/chains.git
synced 2024-07-29 22:37:19 +00:00
Check for unused explorer icons
This commit is contained in:
parent
64a742ad9e
commit
105c884c35
|
@ -269,13 +269,7 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonObject["icon"]?.let {
|
jsonObject["icon"]?.let {
|
||||||
if (it !is String) {
|
processIcon(it, chainFile)
|
||||||
error("icon must be string")
|
|
||||||
}
|
|
||||||
if (!File(iconsPath, "$it.json").exists()) {
|
|
||||||
error("The Icon $it does not exist - was used in ${chainFile.name}")
|
|
||||||
}
|
|
||||||
allUsedIcons.add(it)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val nameRegex = Regex("^[a-zA-Z0-9\\-\\.\\(\\) ]+$")
|
val nameRegex = Regex("^[a-zA-Z0-9\\-\\.\\(\\) ]+$")
|
||||||
|
@ -330,8 +324,8 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
|
||||||
throw (ExplorerMustHaveName())
|
throw (ExplorerMustHaveName())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (explorer["icon"] != null) {
|
explorer["icon"]?.let { explorerIcon ->
|
||||||
allUsedIcons.add(explorer["icon"].toString())
|
processIcon(explorerIcon, chainFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
val url = explorer["url"]
|
val url = explorer["url"]
|
||||||
|
@ -477,6 +471,16 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun processIcon(it: Any, chainFile: File): Boolean {
|
||||||
|
if (it !is String) {
|
||||||
|
error("icon must be string")
|
||||||
|
}
|
||||||
|
if (!File(iconsPath, "$it.json").exists()) {
|
||||||
|
error("The Icon $it does not exist - was used in ${chainFile.name}")
|
||||||
|
}
|
||||||
|
return allUsedIcons.add(it)
|
||||||
|
}
|
||||||
|
|
||||||
private fun String.checkString(which: String) {
|
private fun String.checkString(which: String) {
|
||||||
if (isBlank()) {
|
if (isBlank()) {
|
||||||
throw StringCannotBeBlank(which)
|
throw StringCannotBeBlank(which)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user