From d5dfe57a1d810fe7fd64edefc976633ee3a4da53 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 12 Oct 2019 00:00:50 +0200 Subject: [PATCH] fix: resolve circular dependency in pack.js `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: https://github.com/nodejs/node/pull/29935 PR-URL: https://github.com/npm/cli/pull/266 Credit: @addaleax Close: #266 Reviewed-by: @mikemimik --- lib/pack.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pack.js b/lib/pack.js index 78e5bfd174d7b..8189cb6cedc0b 100644 --- a/lib/pack.js +++ b/lib/pack.js @@ -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') @@ -37,7 +40,6 @@ pack.usage = 'npm pack [[<@scope>/]...] [--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') {