Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pack: do not show individual files of bundled deps #2050

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: [email protected]
=== Tarball Contents ===
4B node_modules/bundle-dep
97B package.json
97B package.json
=== Bundled Dependencies ===
bundle-dep
Expand Down