-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix: issue-6960 Correctly handle scenario where prefix is the current working directory #7208
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
Closed
ficocelliguy
wants to merge
2
commits into
npm:latest
from
ficocelliguy:6960_fix_local_directory_prefix_usage
Closed
fix: issue-6960 Correctly handle scenario where prefix is the current working directory #7208
ficocelliguy
wants to merge
2
commits into
npm:latest
from
ficocelliguy:6960_fix_local_directory_prefix_usage
Conversation
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
2 tasks
…rectory_prefix_usage
@@ -129,6 +129,25 @@ t.test('exec commands', async t => { | |||
await npm.exec('install') | |||
}) | |||
|
|||
await t.test('should not self-install package if prefix is the same as PWD', async t => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean "CWD" instead of "PWD" here?
wraithgar
reviewed
Apr 9, 2025
@@ -131,7 +131,7 @@ class Install extends ArboristWorkspaceCmd { | |||
args = args.filter(a => resolve(a) !== this.npm.prefix) | |||
|
|||
// `npm i -g` => "install this package globally" | |||
if (where === globalTop && !args.length) { | |||
if (isGlobalInstall && where === globalTop && !args.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where
is already coupled to isGlobalInstall
:
const isGlobalInstall = this.npm.global
const where = isGlobalInstall ? globalTop : this.npm.prefix
I suspect we don't need both tested here.
closing in favor of #8269 |
wraithgar
pushed a commit
that referenced
this pull request
May 5, 2025
closes #6960 related #7208 resolves feedback from #7208 (comment) and #7208 (review) Manually verified the fix on windows Co-authored-by: Michael Ficocelli <ficocemt@gmail.com>
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.
closes #6960
Currently, when running
npm install
, if the--prefix
flag is provided and set to the current working directory, this triggers some logic intended for a global install. Specifically, it makesnpm.globalDir
andnpm.prefix
the same. This causes the package ["."] to be included in the dependencies needed, adding a reference to the current directory to package.json as an emptyfile:
dependency.This PR ensures that the global install logic in
install.js
is only run for global installs.