diff --git a/lib/pack.js b/lib/pack.js index 14f63d83c0b7e..20e518484c0dc 100644 --- a/lib/pack.js +++ b/lib/pack.js @@ -27,7 +27,7 @@ const pack = async (args) => { for (const tar of tarballs) { logTar(tar, { log, unicode }) - output(tar.filename) + output(tar.filename.replace(/^@/, '').replace(/\//, '-')) } } @@ -36,6 +36,7 @@ const pack_ = async (arg, opts) => { const { dryRun } = opts const manifest = await pacote.manifest(spec, opts) const filename = `${manifest.name}-${manifest.version}.tgz` + .replace(/^@/, '').replace(/\//, '-') const tarballData = await libpack(arg, opts) const pkgContents = await getContents(manifest, tarballData) diff --git a/test/lib/pack.js b/test/lib/pack.js index 9cb867d670782..097204ea92bea 100644 --- a/test/lib/pack.js +++ b/test/lib/pack.js @@ -78,6 +78,40 @@ t.test('should pack given directory', (t) => { }) }) +t.test('should pack given directory for scoped package', (t) => { + const testDir = t.testdir({ + 'package.json': JSON.stringify({ + name: '@cool/my-pkg', + version: '1.0.0' + }, null, 2) + }) + + const pack = requireInject('../../lib/pack.js', { + '../../lib/utils/output.js': output, + '../../lib/npm.js': { + flatOptions: { + unicode: true, + json: true, + dryRun: true + } + }, + libnpmpack, + npmlog: { + notice: () => {}, + 'showProgress': () => {}, + 'clearProgress': () => {} + } + }) + + return pack([testDir], er => { + if (er) { + throw er + } + const filename = 'cool-my-pkg-1.0.0.tgz' + t.strictSame(OUTPUT, [[filename]]) + }) +}) + t.test('should log pack contents', (t) => { const pack = requireInject('../../lib/pack.js', { '../../lib/utils/output.js': output,