Skip to content

Commit

Permalink
pack: do not show individual files of bundled deps
Browse files Browse the repository at this point in the history
We show a list of bundled dependencies, there's no need to ALSO show
the individual files in each one.

PR-URL: #2050
Credit: @isaacs
Close: #2050
Reviewed-by: @nlf
  • Loading branch information
isaacs authored and nlf committed Oct 27, 2020
1 parent f8f6e1f commit 5db95b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
15 changes: 7 additions & 8 deletions lib/utils/tar.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
'use strict'

const tar = require('tar')
const ssri = require('ssri')
const npmlog = require('npmlog')
const byteSize = require('byte-size')
const columnify = require('columnify')

module.exports = { logTar, getContents }

function logTar (tarball, opts = {}) {
const logTar = (tarball, opts = {}) => {
const { unicode = false, log = npmlog } = opts
log.notice('')
log.notice('', `${unicode ? '📦 ' : 'package:'} ${tarball.name}@${tarball.version}`)
log.notice('=== Tarball Contents ===')
if (tarball.files.length) {
log.notice('', columnify(tarball.files.map((f) => {
const bytes = byteSize(f.size)
return { path: f.path, size: `${bytes.value}${bytes.unit}` }
}), {
return (/^node_modules\//.test(f.path)) ? null
: { path: f.path, size: `${bytes.value}${bytes.unit}` }
}).filter(f => f), {
include: ['size', 'path'],
showHeaders: false,
}))
Expand Down Expand Up @@ -49,7 +46,7 @@ function logTar (tarball, opts = {}) {
log.notice('', '')
}

async function getContents (manifest, tarball) {
const getContents = async (manifest, tarball) => {
const files = []
const bundled = new Set()
let totalEntries = 0
Expand Down Expand Up @@ -111,3 +108,5 @@ async function getContents (manifest, tarball) {
bundled: Array.from(bundled),
}
}

module.exports = { logTar, getContents }
3 changes: 1 addition & 2 deletions tap-snapshots/test-lib-utils-tar.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ exports[`test/lib/utils/tar.js TAP should log tarball contents > must match snap
package: my-cool-pkg@1.0.0
=== Tarball Contents ===
4B node_modules/bundle-dep
97B package.json
97B package.json
=== Bundled Dependencies ===
bundle-dep
Expand Down

0 comments on commit 5db95b3

Please sign in to comment.