-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In its latest release, byte-size dropped support for node versions lower than 14. The cli currently supports node 10 and up. The actual functionality we needed and was using was extremely limited in scope, and didn't warrant an external module. It's just pretty printing a file size, and the files we are dealing with are limited in size so we don't need to support so many suffixes.
- Loading branch information
Showing
11 changed files
with
47 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Convert bytes to printable output, for file reporting in tarballs | ||
// Only supports up to GB because that's way larger than anything the registry | ||
// supports anyways. | ||
|
||
const formatBytes = (bytes, space = true) => { | ||
let spacer = '' | ||
if (space) | ||
spacer = ' ' | ||
|
||
if (bytes < 1000) // B | ||
return `${bytes}${spacer}B` | ||
|
||
if (bytes < 1000000) // kB | ||
return `${(bytes / 1000).toFixed(1)}${spacer}kB` | ||
|
||
if (bytes < 1000000000) // MB | ||
return `${(bytes / 1000000).toFixed(1)}${spacer}MB` | ||
|
||
return `${(bytes / 1000000000).toFixed(1)}${spacer}GB` | ||
} | ||
|
||
module.exports = formatBytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.