Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consolidate registryConfig application logic #4775

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions lib/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 })
}
Expand Down Expand Up @@ -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
32 changes: 0 additions & 32 deletions tap-snapshots/test/lib/commands/ls.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,6 @@ [email protected]

`

exports[`test/lib/commands/ls.js TAP ls --only=development > should output tree containing only development deps 1`] = `
[email protected] {CWD}/tap-testdir-ls-ls---only-development
\`-- [email protected]
\`-- [email protected]
\`-- [email protected]

`

exports[`test/lib/commands/ls.js TAP ls --only=prod > should output tree containing only prod deps 1`] = `
[email protected] {CWD}/tap-testdir-ls-ls---only-prod
+-- [email protected]
+-- [email protected]
\`-- [email protected]
\`-- [email protected]

`

exports[`test/lib/commands/ls.js TAP ls --parseable --depth=0 > should output tree containing only top-level dependencies 1`] = `
{CWD}/tap-testdir-ls-ls---parseable---depth-0
{CWD}/tap-testdir-ls-ls---parseable---depth-0/node_modules/chai
Expand Down Expand Up @@ -204,21 +187,6 @@ exports[`test/lib/commands/ls.js TAP ls --parseable --long with extraneous deps
{CWD}/tap-testdir-ls-ls---parseable---long-with-extraneous-deps/node_modules/dog:[email protected]
`

exports[`test/lib/commands/ls.js TAP ls --parseable --only=development > should output tree containing only development deps 1`] = `
{CWD}/tap-testdir-ls-ls---parseable---only-development
{CWD}/tap-testdir-ls-ls---parseable---only-development/node_modules/dev-dep
{CWD}/tap-testdir-ls-ls---parseable---only-development/node_modules/foo
{CWD}/tap-testdir-ls-ls---parseable---only-development/node_modules/dog
`

exports[`test/lib/commands/ls.js TAP ls --parseable --only=prod > should output tree containing only prod deps 1`] = `
{CWD}/tap-testdir-ls-ls---parseable---only-prod
{CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/chai
{CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/optional-dep
{CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/prod-dep
{CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/prod-dep/node_modules/dog
`

ruyadorno marked this conversation as resolved.
Show resolved Hide resolved
exports[`test/lib/commands/ls.js TAP ls --parseable --production > should output tree containing production deps 1`] = `
{CWD}/tap-testdir-ls-ls---parseable---production
{CWD}/tap-testdir-ls-ls---parseable---production/node_modules/chai
Expand Down
Loading