mirror of
				https://github.com/Instadapp/trustwallet-assets.git
				synced 2024-07-29 22:37:31 +00:00 
			
		
		
		
	 9f4ed41dd6
			
		
	
	
		9f4ed41dd6
		
			
		
	
	
	
	
		
			
			* 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>
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			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)
 | |
|             }
 | |
|         }
 | |
|     })
 | |
| })
 | |
| 
 |