Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2020-10-27 01:49:19 +0300
committernlf <quitlahok@gmail.com>2020-10-27 21:38:10 +0300
commit5db95b393e9c461ad34c1774f3515c322bf375bf (patch)
treedccdacb73927e774427d09aa4de213b02762b248 /lib/utils
parentf8f6e1fad8057edc02e4ce4382b1bc086d01211c (diff)
pack: do not show individual files of bundled deps
We show a list of bundled dependencies, there's no need to ALSO show the individual files in each one. PR-URL: https://github.com/npm/cli/pull/2050 Credit: @isaacs Close: #2050 Reviewed-by: @nlf
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/tar.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/utils/tar.js b/lib/utils/tar.js
index 9e3c7ec25..887c40a0f 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 }