forked from trustwallet/assets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat_files_name.ts
42 lines (37 loc) · 1.21 KB
/
format_files_name.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)
readDirSync(assetsPath).forEach(address => {
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)
}
})
checksumAssetsFolder(assetsPath, address)
})
})
export function checksumAssetsFolder(assetsFolderPath: string, addr: string) {
if (!isChecksum(addr)) {
renameAndMove(assetsFolderPath, addr, toChecksum(addr))
}
}
export function renameAndMove(path: string, oldName: string, newName: string) {
console.log(` Renaming file or folder at path ${path}: ${oldName} => ${newName}`)
execRename(path, getMoveCommandFromTo(oldName, newName))
}