Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
fix(child): only override dirPacker if opts.dirPacker is defined (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
edahlseng authored and zkat committed Aug 9, 2018
1 parent cc72f31 commit 13ab2f0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ module.exports = {

child (name, child, childPath, config, opts) {
const spec = npa.resolve(name, child.version)
const additionalToPacoteOpts = {}
if (typeof opts.dirPacker !== 'undefined') {
additionalToPacoteOpts.dirPacker = opts.dirPacker
}
const childOpts = config.toPacote(Object.assign({
integrity: child.integrity,
resolved: child.resolved
}, {
dirPacker: opts.dirPacker
}))
}, additionalToPacoteOpts))
const args = [spec, childPath, childOpts]
return BB.fromNode((cb) => {
let launcher = extractionWorker
Expand Down
30 changes: 30 additions & 0 deletions test/specs/lib/extract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict'

const test = require('tap').test
const requireInject = require('require-inject')

const extract = requireInject('../../../lib/extract.js', {
'../../../lib/worker.js': (msg, cb) => { cb(null, msg) },
'npm-package-arg': {
resolve: () => ({ registry: false, type: 'not-remote' })
}
})

test('extract.child() only overwrites dirPacker when opts.dirPacker is defined', t => {
const name = 'name'
const child = { version: '0.0.0', integrity: 'integrity', resolved: 'resolved' }
const childPath = './path'
const config = {
toPacote (moreOpts) {
return moreOpts
}
}

const opts = { log: { level: 'level' } }
const a = extract.child(name, child, childPath, config, opts)

a.then(b => {
t.ok(!('dirPacker' in b[2]), 'An undefined dirPacker overrode the pacote childOpts')
t.end()
})
})

0 comments on commit 13ab2f0

Please sign in to comment.