diff --git a/lib/utils/tar.js b/lib/utils/tar.js index 9e3c7ec25cea6..887c40a0f6ebe 100644 --- a/lib/utils/tar.js +++ b/lib/utils/tar.js @@ -1,14 +1,10 @@ -'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}`) @@ -16,8 +12,9 @@ function logTar (tarball, opts = {}) { 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, })) @@ -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 @@ -111,3 +108,5 @@ async function getContents (manifest, tarball) { bundled: Array.from(bundled), } } + +module.exports = { logTar, getContents } diff --git a/tap-snapshots/test-lib-utils-tar.js-TAP.test.js b/tap-snapshots/test-lib-utils-tar.js-TAP.test.js index 72b46004b684c..402a0e735afc4 100644 --- a/tap-snapshots/test-lib-utils-tar.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-tar.js-TAP.test.js @@ -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