trustwallet-assets/script/arrange_files.ts
EtherX Project 9f4ed41dd6
Upload EtherX Token (#1509)
* Add files via upload

* Add script to move files /assets/0x..XX.png => /asstes/0x..XX/logo.png

Co-authored-by: Mykola <3277207+kolya182@users.noreply.github.com>
Co-authored-by: Mykola <kolya182@gmail.com>
2020-03-20 15:16:45 -07:00

39 lines
1.1 KiB
TypeScript

import * as fs from "fs"
import {
ethSidechains,
getChainAssetPath,
getChainAssetsPath,
getFileExt,
getFileName,
isChecksum,
isPathDir,
logo,
logoExtension,
makeDirIfDoestExist,
readDirSync,
toChecksum,
} from "../src/test/helpers"
ethSidechains.forEach(chain => {
const assetsPath = getChainAssetsPath(chain)
const chainAssets = readDirSync(assetsPath)
chainAssets.forEach(async asset => {
const assetPath = getChainAssetPath(chain, asset)
const isDir = await isPathDir(assetPath)
if (!isDir) {
const assetName = getFileName(asset)
const checksum = toChecksum(assetName)
if (isChecksum(checksum) && getFileExt(asset).toLocaleLowerCase() === logoExtension) {
// Moves file like /assets/0x..XX.png => /asstes/0x..XX/logo.png
await makeDirIfDoestExist(assetsPath, checksum)
const newPath = `${assetsPath}/${checksum}/${logo}`
fs.renameSync(assetPath, newPath)
}
}
})
})