Skip to content

Commit ced0acf

Browse files
wraithgarlukekarrys
authored andcommitted
fix: consolidate registryConfig application logic
It should happen whenever we read a manifest anyways. Tests were also rewritten to be real.
1 parent 4a46a27 commit ced0acf

File tree

4 files changed

+715
-886
lines changed

4 files changed

+715
-886
lines changed

lib/commands/publish.js

+15-16
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ class Publish extends BaseCommand {
6969
const spec = npa(args[0])
7070
let manifest = await this.getManifest(spec, opts)
7171

72-
if (manifest.publishConfig) {
73-
flatten(manifest.publishConfig, opts)
74-
}
75-
7672
// only run scripts for directory type publishes
7773
if (spec.type === 'directory' && !ignoreScripts) {
7874
await runScript({
@@ -92,12 +88,8 @@ class Publish extends BaseCommand {
9288
// so that we send the latest and greatest thing to the registry
9389
// note that publishConfig might have changed as well!
9490
manifest = await this.getManifest(spec, opts)
95-
if (manifest.publishConfig) {
96-
flatten(manifest.publishConfig, opts)
97-
}
9891

99-
// note that logTar calls log.notice(), so if we ARE in silent mode,
100-
// this will do nothing, but we still want it in the debuglog if it fails.
92+
// JSON already has the package contents
10193
if (!json) {
10294
logTar(pkgContents, { unicode })
10395
}
@@ -197,15 +189,22 @@ class Publish extends BaseCommand {
197189

198190
// if it's a directory, read it from the file system
199191
// otherwise, get the full metadata from whatever it is
200-
getManifest (spec, opts) {
192+
// XXX can't pacote read the manifest from a directory?
193+
async getManifest (spec, opts) {
194+
let manifest
201195
if (spec.type === 'directory') {
202-
return readJson(`${spec.fetchSpec}/package.json`)
196+
manifest = await readJson(`${spec.fetchSpec}/package.json`)
197+
} else {
198+
manifest = await pacote.manifest(spec, {
199+
...opts,
200+
fullmetadata: true,
201+
fullReadJson: true,
202+
})
203+
}
204+
if (manifest.publishConfig) {
205+
flatten(manifest.publishConfig, opts)
203206
}
204-
return pacote.manifest(spec, {
205-
...opts,
206-
fullMetadata: true,
207-
fullReadJson: true,
208-
})
207+
return manifest
209208
}
210209
}
211210
module.exports = Publish

0 commit comments

Comments
 (0)