Skip to content

Commit

Permalink
deps: move from byte-size to pretty-bytes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wraithgar committed Jul 22, 2021
1 parent 8dc74de commit db0073e
Show file tree
Hide file tree
Showing 13 changed files with 328 additions and 338 deletions.
10 changes: 5 additions & 5 deletions lib/utils/tar.js
@@ -1,7 +1,7 @@
const tar = require('tar')
const ssri = require('ssri')
const npmlog = require('npmlog')
const byteSize = require('byte-size')
const prettyBytes = require('pretty-bytes')
const columnify = require('columnify')

const logTar = (tarball, opts = {}) => {
Expand All @@ -11,9 +11,9 @@ const logTar = (tarball, opts = {}) => {
log.notice('=== Tarball Contents ===')
if (tarball.files.length) {
log.notice('', columnify(tarball.files.map((f) => {
const bytes = byteSize(f.size)
const bytes = prettyBytes(f.size)
return (/^node_modules\//.test(f.path)) ? null
: { path: f.path, size: `${bytes.value}${bytes.unit}` }
: { path: f.path, size: `${bytes.replace(' ', '')}` }
}).filter(f => f), {
include: ['size', 'path'],
showHeaders: false,
Expand All @@ -28,8 +28,8 @@ const logTar = (tarball, opts = {}) => {
{ name: 'name:', value: tarball.name },
{ name: 'version:', value: tarball.version },
tarball.filename && { name: 'filename:', value: tarball.filename },
{ name: 'package size:', value: byteSize(tarball.size) },
{ name: 'unpacked size:', value: byteSize(tarball.unpackedSize) },
{ name: 'package size:', value: prettyBytes(tarball.size) },
{ name: 'unpacked size:', value: prettyBytes(tarball.unpackedSize) },
{ name: 'shasum:', value: tarball.shasum },
{
name: 'integrity:',
Expand Down
6 changes: 3 additions & 3 deletions lib/view.js
@@ -1,13 +1,13 @@
// npm view [pkg [pkg ...]]

const byteSize = require('byte-size')
const color = require('ansicolors')
const columns = require('cli-columns')
const fs = require('fs')
const jsonParse = require('json-parse-even-better-errors')
const log = require('npmlog')
const npa = require('npm-package-arg')
const { resolve } = require('path')
const prettyBytes = require('pretty-bytes')
const relativeDate = require('tiny-relative-date')
const semver = require('semver')
const style = require('ansistyles')
Expand Down Expand Up @@ -315,7 +315,7 @@ class View extends BaseCommand {
tags.push(`${style.bright(color.green(t))}: ${version}`)
})
const unpackedSize = manifest.dist.unpackedSize &&
byteSize(manifest.dist.unpackedSize)
prettyBytes(manifest.dist.unpackedSize).split(' ')
const licenseField = manifest.license || 'Proprietary'
const info = {
name: color.green(manifest.name),
Expand Down Expand Up @@ -356,7 +356,7 @@ class View extends BaseCommand {
manifest.dist.integrity && color.yellow(manifest.dist.integrity),
fileCount:
manifest.dist.fileCount && color.yellow(manifest.dist.fileCount),
unpackedSize: unpackedSize && color.yellow(unpackedSize.value) + ' ' + unpackedSize.unit,
unpackedSize: unpackedSize && color.yellow(unpackedSize[0]) + ' ' + unpackedSize[1],
}
if (info.license.toLowerCase().trim() === 'proprietary')
info.license = style.bright(color.red(info.license))
Expand Down
21 changes: 0 additions & 21 deletions node_modules/byte-size/LICENSE

This file was deleted.

123 changes: 0 additions & 123 deletions node_modules/byte-size/dist/index.js

This file was deleted.

115 changes: 0 additions & 115 deletions node_modules/byte-size/index.mjs

This file was deleted.

55 changes: 0 additions & 55 deletions node_modules/byte-size/package.json

This file was deleted.

0 comments on commit db0073e

Please sign in to comment.