Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use standardized units in text outputs #3784

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/api/api_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,13 +1146,13 @@ func (ctx *internalContext) Dispose() {
func prettyPrintByteCount(n int) string {
var size string
if n < 1024 {
size = fmt.Sprintf("%db ", n)
size = fmt.Sprintf("%dB ", n)
} else if n < 1024*1024 {
size = fmt.Sprintf("%.1fkb", float64(n)/(1024))
size = fmt.Sprintf("%.1fKiB", float64(n)/(1024))
} else if n < 1024*1024*1024 {
size = fmt.Sprintf("%.1fmb", float64(n)/(1024*1024))
size = fmt.Sprintf("%.1fMiB", float64(n)/(1024*1024))
} else {
size = fmt.Sprintf("%.1fgb", float64(n)/(1024*1024*1024))
size = fmt.Sprintf("%.1fGiB", float64(n)/(1024*1024*1024))
}
return size
}
Expand Down
24 changes: 12 additions & 12 deletions scripts/js-api-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6962,15 +6962,15 @@ let analyzeTests = {
}
}
assert.strictEqual(await esbuild.analyzeMetafile(metafile), `
out.js 100b 100.0%
├ lib.js 50b 50.0%
└ entry.js 25b 25.0%
out.js 100B 100.0%
├ lib.js 50B 50.0%
└ entry.js 25B 25.0%
`)
assert.strictEqual(await esbuild.analyzeMetafile(metafile, { verbose: true }), `
out.js ────── 100b ── 100.0%
├ lib.js ──── 50b ─── 50.0%
out.js ────── 100B ─── 100.0%
├ lib.js ──── 50B ──── 50.0%
│ └ entry.js
└ entry.js ── 25b ─── 25.0%
└ entry.js ── 25B ──── 25.0%
`)
},
}
Expand Down Expand Up @@ -7192,15 +7192,15 @@ ${path.relative(process.cwd(), input).split(path.sep).join('/')}:1:2: ERROR: Une
}
}
assert.strictEqual(esbuild.analyzeMetafileSync(metafile), `
out.js 100b 100.0%
├ lib.js 50b 50.0%
└ entry.js 25b 25.0%
out.js 100B 100.0%
├ lib.js 50B 50.0%
└ entry.js 25B 25.0%
`)
assert.strictEqual(esbuild.analyzeMetafileSync(metafile, { verbose: true }), `
out.js ────── 100b ── 100.0%
├ lib.js ──── 50b ─── 50.0%
out.js ────── 100B ─── 100.0%
├ lib.js ──── 50B ──── 50.0%
│ └ entry.js
└ entry.js ── 25b ─── 25.0%
└ entry.js ── 25B ──── 25.0%
`)
},
}
Expand Down