mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
chore: simplify tree
This commit is contained in:
parent
6875d5535b
commit
8b071c4efd
@ -1,4 +1,4 @@
|
|||||||
import { resolve, extname, basename, dirname, relative } from 'path'
|
import { resolve, dirname, relative } from 'path'
|
||||||
import globby from 'globby'
|
import globby from 'globby'
|
||||||
import prettyBytes from 'pretty-bytes'
|
import prettyBytes from 'pretty-bytes'
|
||||||
import gzipSize from 'gzip-size'
|
import gzipSize from 'gzip-size'
|
||||||
@ -19,16 +19,16 @@ export async function printFSTree (dir) {
|
|||||||
let totalSize = 0
|
let totalSize = 0
|
||||||
let totalGzip = 0
|
let totalGzip = 0
|
||||||
|
|
||||||
for (const item of items) {
|
items.forEach((item, index) => {
|
||||||
let dir = dirname(item.file)
|
let dir = dirname(item.file)
|
||||||
if (dir === '.') { dir = '' }
|
if (dir === '.') { dir = '' }
|
||||||
const name = basename(item.file, extname(item.file))
|
|
||||||
const rpath = relative(process.cwd(), item.path)
|
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
|
totalSize += item.size
|
||||||
totalGzip += item.gzip
|
totalGzip += item.gzip
|
||||||
}
|
})
|
||||||
|
|
||||||
process.stdout.write(`${chalk.cyan('λ Total size:')} ${prettyBytes(totalSize)} (${prettyBytes(totalGzip)} gzip)\n`)
|
process.stdout.write(`${chalk.cyan('λ Total size:')} ${prettyBytes(totalSize)} (${prettyBytes(totalGzip)} gzip)\n`)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user