-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Fix numeric versions resolving to local files (#4088)
**Summary** Fixes #4013. We were blindly priotizing local files (even if they are not directories) if there's anything on the file system matching a pattern for a package. This patch ensures that we only do this if the pattern is not a valid semver range and the matched local entity is a directory. **Test plan** Added a new unit test and modified an incorrect old one. Also manually verified that the issue described in #4013 does not happen anymore.
- Loading branch information
Showing
11 changed files
with
68 additions
and
11 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
__tests__/commands/install/__snapshots__/integration.js.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`install-file-as-default-no-semver 1`] = ` | ||
"{ | ||
\\"author\\": \\"AJ ONeal <coolaj86@gmail.com> (http://coolaj86.info)\\", | ||
\\"name\\": \\"foo\\", | ||
\\"description\\": \\"A test module with no \`main\`, \`lib\`, or \`dependencies\` specified\\", | ||
\\"version\\": \\"1.0.0\\", | ||
\\"repository\\": { | ||
\\"type\\": \\"git\\", | ||
\\"url\\": \\"git://github.com/coolaj86/node-pakman.git\\" | ||
}, | ||
\\"engines\\": { | ||
\\"node\\": \\">= v0.2\\" | ||
} | ||
} | ||
" | ||
`; |
This file contains 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
Empty file.
5 changes: 5 additions & 0 deletions
5
__tests__/fixtures/install/install-file-as-default-no-file/package.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"foo": "bar" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
__tests__/fixtures/install/install-file-as-default-no-semver/1/index.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foobar; |
5 changes: 5 additions & 0 deletions
5
__tests__/fixtures/install/install-file-as-default-no-semver/1/package.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "1", | ||
"version": "0.0.0", | ||
"main": "index.js" | ||
} |
5 changes: 5 additions & 0 deletions
5
__tests__/fixtures/install/install-file-as-default-no-semver/package.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"foo": "1" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
__tests__/fixtures/install/install-file-as-default-no-semver/yarn.lock
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
"foo@file:bar": | ||
version "0.0.0" |
Binary file not shown.
Binary file added
BIN
+10.7 KB
__tests__/fixtures/request-cache/GET/registry.yarnpkg.com/foo/-/foo-1.0.0.tgz.bin
Binary file not shown.
This file contains 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