chore: simplify tree

This commit is contained in:
Pooya Parsa 2020-11-14 21:47:14 +01:00
parent 6875d5535b
commit 8b071c4efd
1 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { resolve, extname, basename, dirname, relative } from 'path'
import { resolve, dirname, relative } from 'path'
import globby from 'globby'
import prettyBytes from 'pretty-bytes'
import gzipSize from 'gzip-size'
@ -19,16 +19,16 @@ export async function printFSTree (dir) {
let totalSize = 0
let totalGzip = 0
for (const item of items) {
items.forEach((item, index) => {
let dir = dirname(item.file)
if (dir === '.') { dir = '' }
const name = basename(item.file, extname(item.file))
const rpath = relative(process.cwd(), item.path)
process.stdout.write(chalk.gray(`[${dir ? `${dir}/` : ''}${name}] at ${rpath} (${prettyBytes(item.size)}) (${prettyBytes(item.gzip)} gzip)\n`))
const treeChar = index === items.length - 1 ? '└─' : '├─'
process.stdout.write(chalk.gray(` ${treeChar} ${rpath} (${prettyBytes(item.size)}) (${prettyBytes(item.gzip)} gzip)\n`))
totalSize += item.size
totalGzip += item.gzip
}
})
process.stdout.write(`${chalk.cyan('λ Total size:')} ${prettyBytes(totalSize)} (${prettyBytes(totalGzip)} gzip)\n`)
}