File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { UI } from "../ui"
33import * as prompts from "@clack/prompts"
44import { Installation } from "../../installation"
55import { Global } from "../../global"
6+ import { formatSize } from "../../util/format"
67import { $ } from "bun"
78import fs from "fs/promises"
89import path from "path"
@@ -341,13 +342,6 @@ async function getDirectorySize(dir: string): Promise<number> {
341342 return total
342343}
343344
344- function formatSize ( bytes : number ) : string {
345- if ( bytes < 1024 ) return `${ bytes } B`
346- if ( bytes < 1024 * 1024 ) return `${ ( bytes / 1024 ) . toFixed ( 1 ) } KB`
347- if ( bytes < 1024 * 1024 * 1024 ) return `${ ( bytes / ( 1024 * 1024 ) ) . toFixed ( 1 ) } MB`
348- return `${ ( bytes / ( 1024 * 1024 * 1024 ) ) . toFixed ( 1 ) } GB`
349- }
350-
351345function shortenPath ( p : string ) : string {
352346 const home = os . homedir ( )
353347 if ( p . startsWith ( home ) ) {
Original file line number Diff line number Diff line change 1+ export function formatSize ( bytes : number ) : string {
2+ if ( bytes < 1024 ) return `${ bytes } B`
3+ if ( bytes < 1024 * 1024 ) return `${ ( bytes / 1024 ) . toFixed ( 1 ) } KB`
4+ if ( bytes < 1024 * 1024 * 1024 ) return `${ ( bytes / ( 1024 * 1024 ) ) . toFixed ( 1 ) } MB`
5+ return `${ ( bytes / ( 1024 * 1024 * 1024 ) ) . toFixed ( 1 ) } GB`
6+ }
7+
18export function formatDuration ( secs : number ) {
29 if ( secs <= 0 ) return ""
310 if ( secs < 60 ) return `${ secs } s`
You can’t perform that action at this time.
0 commit comments