Skip to content

Commit

Permalink
fix: resolve circular dependency in pack.js
Browse files Browse the repository at this point in the history
`lib/pack.js` and `lib/config/figgy-config.js` load each other,
making `figgy-config.js` grab the original `module.exports` value
and not the intended one. In particular, this always sets the
`dirPacker` value to `undefined` in the config generation step.

Fix this by setting `module.exports` early.

Refs: nodejs/node#29935

PR-URL: #266
Credit: @addaleax
Close: #266
Reviewed-by: @mikemimik
  • Loading branch information
addaleax authored and Michael Perrotte committed Oct 29, 2019
1 parent b6588a8 commit d5dfe57
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/pack.js
Expand Up @@ -4,6 +4,9 @@
// Packs the specified package into a .tgz file, which can then
// be installed.

// Set this early to avoid issues with circular dependencies.
module.exports = pack

const BB = require('bluebird')

const byteSize = require('byte-size')
Expand Down Expand Up @@ -37,7 +40,6 @@ pack.usage = 'npm pack [[<@scope>/]<pkg>...] [--dry-run]'
// if it can be installed, it can be packed.
pack.completion = install.completion

module.exports = pack
function pack (args, silent, cb) {
const cwd = process.cwd()
if (typeof cb !== 'function') {
Expand Down

0 comments on commit d5dfe57

Please sign in to comment.