trustwallet-assets/script-old/remove_empty_folder.ts

27 lines
739 B
TypeScript
Raw Normal View History

2020-05-18 01:20:58 +00:00
import {
getChainAssetPath,
getChainAssetsPath,
isPathDir,
isPathDirEmpty,
2020-05-18 01:20:58 +00:00
readDirSync,
removeDir,
getAllChainsList,
} from "./helpers"
2020-05-18 01:20:58 +00:00
getAllChainsList().forEach(async chain => {
const chainAssetsPath = getChainAssetsPath(chain)
if (isPathDir(chainAssetsPath)) {
readDirSync(chainAssetsPath).forEach(async (asset) => {
const assetPath = getChainAssetPath(chain, asset);
const isDir = await isPathDir(assetPath);
const isPathEmpty = await isPathDirEmpty(assetPath);
2020-05-18 01:20:58 +00:00
if (isDir && isPathEmpty) {
2020-05-18 01:20:58 +00:00
removeDir(assetPath)
console.log(`Removed empty folder at path ${assetPath}`);
}
})
}
})