Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2022-04-19 21:29:05 +0300
committerLuke Karrys <luke@lukekarrys.com>2022-04-20 02:25:15 +0300
commitced0acfe5998a5be9313815f76f5c1439a09db78 (patch)
tree805489670e3cb0b0ac01619b7ad33e02771982e3 /lib
parent4a46a27f2b968e2f8c1f4821508f93013738c482 (diff)
fix: consolidate registryConfig application logic
It should happen whenever we read a manifest anyways. Tests were also rewritten to be real.
Diffstat (limited to 'lib')
-rw-r--r--lib/commands/publish.js31
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/commands/publish.js b/lib/commands/publish.js
index 51861c5aa..ff3036693 100644
--- a/lib/commands/publish.js
+++ b/lib/commands/publish.js
@@ -69,10 +69,6 @@ class Publish extends BaseCommand {
const spec = npa(args[0])
let manifest = await this.getManifest(spec, opts)
- if (manifest.publishConfig) {
- flatten(manifest.publishConfig, opts)
- }
-
// only run scripts for directory type publishes
if (spec.type === 'directory' && !ignoreScripts) {
await runScript({
@@ -92,12 +88,8 @@ class Publish extends BaseCommand {
// so that we send the latest and greatest thing to the registry
// note that publishConfig might have changed as well!
manifest = await this.getManifest(spec, opts)
- if (manifest.publishConfig) {
- flatten(manifest.publishConfig, opts)
- }
- // note that logTar calls log.notice(), so if we ARE in silent mode,
- // this will do nothing, but we still want it in the debuglog if it fails.
+ // JSON already has the package contents
if (!json) {
logTar(pkgContents, { unicode })
}
@@ -197,15 +189,22 @@ class Publish extends BaseCommand {
// if it's a directory, read it from the file system
// otherwise, get the full metadata from whatever it is
- getManifest (spec, opts) {
+ // XXX can't pacote read the manifest from a directory?
+ async getManifest (spec, opts) {
+ let manifest
if (spec.type === 'directory') {
- return readJson(`${spec.fetchSpec}/package.json`)
+ manifest = await readJson(`${spec.fetchSpec}/package.json`)
+ } else {
+ manifest = await pacote.manifest(spec, {
+ ...opts,
+ fullmetadata: true,
+ fullReadJson: true,
+ })
+ }
+ if (manifest.publishConfig) {
+ flatten(manifest.publishConfig, opts)
}
- return pacote.manifest(spec, {
- ...opts,
- fullMetadata: true,
- fullReadJson: true,
- })
+ return manifest
}
}
module.exports = Publish