2020-03-20 20:48:55 +00:00
|
|
|
import {
|
|
|
|
ethSidechains,
|
|
|
|
readDirSync,
|
|
|
|
getChainAssetsPath,
|
|
|
|
getChainAssetFilesList,
|
|
|
|
isChecksum,
|
|
|
|
toChecksum,
|
|
|
|
getFileName,
|
|
|
|
getFileExt,
|
|
|
|
getMoveCommandFromTo,
|
|
|
|
execRename,
|
|
|
|
logoName,
|
|
|
|
logoExtension,
|
|
|
|
logo,
|
|
|
|
getChainAssetPath
|
|
|
|
} from "../src/test/helpers"
|
|
|
|
|
|
|
|
ethSidechains.forEach(chain => {
|
|
|
|
const assetsPath = getChainAssetsPath(chain)
|
|
|
|
|
2020-04-17 02:27:40 +00:00
|
|
|
readDirSync(assetsPath).forEach(address => {
|
2020-03-20 20:48:55 +00:00
|
|
|
getChainAssetFilesList(chain, address).forEach(file => {
|
|
|
|
if (getFileName(file) == logoName && getFileExt(file) !== logoExtension) {
|
|
|
|
console.log(`Renaming incorrect asset logo extension ${file} ...`)
|
|
|
|
renameAndMove(getChainAssetPath(chain, address), file, logo)
|
|
|
|
}
|
|
|
|
})
|
2020-04-17 02:27:40 +00:00
|
|
|
checksumAssetsFolder(assetsPath, address)
|
2020-03-20 20:48:55 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
export function checksumAssetsFolder(assetsFolderPath: string, addr: string) {
|
|
|
|
if (!isChecksum(addr)) {
|
2020-04-17 02:27:40 +00:00
|
|
|
renameAndMove(assetsFolderPath, addr, toChecksum(addr))
|
2020-03-20 20:48:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function renameAndMove(path: string, oldName: string, newName: string) {
|
2020-04-17 02:27:40 +00:00
|
|
|
console.log(` Renaming file or folder at path ${path}: ${oldName} => ${newName}`)
|
|
|
|
execRename(path, getMoveCommandFromTo(oldName, newName))
|
2020-03-20 20:48:55 +00:00
|
|
|
}
|
|
|
|
|