Fix pnpm global config selection by version#1914
Open
Cycle1337 wants to merge 2 commits into
Open
Conversation
raineorshine
requested changes
Jul 4, 2026
raineorshine
left a comment
Owner
There was a problem hiding this comment.
Hi, thanks for your contribution.
| } | ||
|
|
||
| /** Reads the pnpm global minimumReleaseAge layer for the current pnpm major version. */ | ||
| const readPnpmGlobalMinimumReleaseAgeLayer = async ( |
Owner
There was a problem hiding this comment.
This function is unnecessary and it would be cleaner to inline.
Comment on lines
+156
to
+165
| if (pnpmMajorVersion != null) { | ||
| return pnpmMajorVersion >= 11 | ||
| ? readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'config.yaml'), 'yaml') | ||
| : readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'rc'), 'ini') | ||
| } | ||
|
|
||
| return ( | ||
| (await readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'config.yaml'), 'yaml')) ?? | ||
| (await readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'rc'), 'ini')) | ||
| ) |
Owner
There was a problem hiding this comment.
This should be structured in a single if statement or ternary to avoid duplication.
Comment on lines
-156
to
-159
| // pnpm >= 11 global config | ||
| readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'config.yaml'), 'yaml'), | ||
| // pnpm <= 10 global config | ||
| readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'rc'), 'ini'), |
Owner
There was a problem hiding this comment.
A cleaner approach would be to inline the ternaries here rather than creating globalConfig variable.
Author
|
Updated based on review:
Re-ran:
|
raineorshine
requested changes
Jul 4, 2026
Comment on lines
+170
to
+178
| // pnpm global config for the current major version | ||
| majorVersion === null | ||
| ? (async () => | ||
| (await readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'config.yaml'), 'yaml')) ?? | ||
| readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'rc'), 'ini'))() | ||
| : readMinimumReleaseAgeLayer( | ||
| path.join(globalConfigDir, majorVersion >= 11 ? 'config.yaml' : 'rc'), | ||
| majorVersion >= 11 ? 'yaml' : 'ini', | ||
| ), |
Owner
There was a problem hiding this comment.
Not quite there yet. This should be structured as a flat list of layered configs.
// pnpm >= 11 global config
CONDITION1 ? readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'config.yaml'), 'yaml') : null,
// pnpm <= 10 global config
CONDITION2 ? readMinimumReleaseAgeLayer(path.join(globalConfigDir, 'rc'), 'ini') : null,
There is still duplication and the nesting is hard to read. Let the layers do the work of prioritizing the configs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1890
Tests