Skip to content

Commit db0073e

Browse files
committed
deps: move from byte-size to pretty-bytes
In its latest release, byte-size dropped support for node versions lower than 14. The cli currently supports node 10 and up. The pretty-bytes module supports (via its github actions testing workflow) node 6 and up.
1 parent 8dc74de commit db0073e

File tree

13 files changed

+328
-338
lines changed

13 files changed

+328
-338
lines changed

lib/utils/tar.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const tar = require('tar')
22
const ssri = require('ssri')
33
const npmlog = require('npmlog')
4-
const byteSize = require('byte-size')
4+
const prettyBytes = require('pretty-bytes')
55
const columnify = require('columnify')
66

77
const logTar = (tarball, opts = {}) => {
@@ -11,9 +11,9 @@ const logTar = (tarball, opts = {}) => {
1111
log.notice('=== Tarball Contents ===')
1212
if (tarball.files.length) {
1313
log.notice('', columnify(tarball.files.map((f) => {
14-
const bytes = byteSize(f.size)
14+
const bytes = prettyBytes(f.size)
1515
return (/^node_modules\//.test(f.path)) ? null
16-
: { path: f.path, size: `${bytes.value}${bytes.unit}` }
16+
: { path: f.path, size: `${bytes.replace(' ', '')}` }
1717
}).filter(f => f), {
1818
include: ['size', 'path'],
1919
showHeaders: false,
@@ -28,8 +28,8 @@ const logTar = (tarball, opts = {}) => {
2828
{ name: 'name:', value: tarball.name },
2929
{ name: 'version:', value: tarball.version },
3030
tarball.filename && { name: 'filename:', value: tarball.filename },
31-
{ name: 'package size:', value: byteSize(tarball.size) },
32-
{ name: 'unpacked size:', value: byteSize(tarball.unpackedSize) },
31+
{ name: 'package size:', value: prettyBytes(tarball.size) },
32+
{ name: 'unpacked size:', value: prettyBytes(tarball.unpackedSize) },
3333
{ name: 'shasum:', value: tarball.shasum },
3434
{
3535
name: 'integrity:',

lib/view.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// npm view [pkg [pkg ...]]
22

3-
const byteSize = require('byte-size')
43
const color = require('ansicolors')
54
const columns = require('cli-columns')
65
const fs = require('fs')
76
const jsonParse = require('json-parse-even-better-errors')
87
const log = require('npmlog')
98
const npa = require('npm-package-arg')
109
const { resolve } = require('path')
10+
const prettyBytes = require('pretty-bytes')
1111
const relativeDate = require('tiny-relative-date')
1212
const semver = require('semver')
1313
const style = require('ansistyles')
@@ -315,7 +315,7 @@ class View extends BaseCommand {
315315
tags.push(`${style.bright(color.green(t))}: ${version}`)
316316
})
317317
const unpackedSize = manifest.dist.unpackedSize &&
318-
byteSize(manifest.dist.unpackedSize)
318+
prettyBytes(manifest.dist.unpackedSize).split(' ')
319319
const licenseField = manifest.license || 'Proprietary'
320320
const info = {
321321
name: color.green(manifest.name),
@@ -356,7 +356,7 @@ class View extends BaseCommand {
356356
manifest.dist.integrity && color.yellow(manifest.dist.integrity),
357357
fileCount:
358358
manifest.dist.fileCount && color.yellow(manifest.dist.fileCount),
359-
unpackedSize: unpackedSize && color.yellow(unpackedSize.value) + ' ' + unpackedSize.unit,
359+
unpackedSize: unpackedSize && color.yellow(unpackedSize[0]) + ' ' + unpackedSize[1],
360360
}
361361
if (info.license.toLowerCase().trim() === 'proprietary')
362362
info.license = style.bright(color.red(info.license))

node_modules/byte-size/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

node_modules/byte-size/dist/index.js

Lines changed: 0 additions & 123 deletions
This file was deleted.

node_modules/byte-size/index.mjs

Lines changed: 0 additions & 115 deletions
This file was deleted.

node_modules/byte-size/package.json

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)