-
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: Don't do range collapsing when using a frozen lockfile (#3604)
**Summary** Fixes #3313. Yarn automatically optimizes less-than-ideal `yarn.lock` files, usually from older versions. That said when run with the `--frozen-lockfile` argument, it should neither touch the lockfile nor throw an exception if the lockfile satisfies all the needs, even if it can be optimized. **Test plan** Existing unit tests plus a new unit test which fails without the fix applied.
- Loading branch information
Showing
13 changed files
with
80 additions
and
17 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -71,6 +71,20 @@ test.concurrent("throws an error if existing lockfile isn't satisfied with --fro | |
expect(thrown).toEqual(true); | ||
}); | ||
|
||
test.concurrent( | ||
"doesn't write new lockfile if existing one satisfied but not fully optimized with --frozen-lockfile", | ||
(): Promise<void> => { | ||
return runInstall( | ||
{frozenLockfile: true}, | ||
'install-should-not-write-lockfile-if-not-optimized-and-frozen', | ||
async (config): Promise<void> => { | ||
const lockfile = await fs.readFile(path.join(config.cwd, 'yarn.lock')); | ||
expect(lockfile.indexOf('[email protected]:')).toBeGreaterThanOrEqual(0); | ||
}, | ||
); | ||
}, | ||
); | ||
|
||
test.concurrent('install transitive optional dependency from lockfile', (): Promise<void> => { | ||
return runInstall({}, 'install-optional-dep-from-lockfile', (config, reporter, install) => { | ||
expect(install && install.resolver && install.resolver.patterns['fsevents@^1.0.0']).toBeTruthy(); | ||
|
6 changes: 6 additions & 0 deletions
6
...xtures/install/install-should-not-write-lockfile-if-not-optimized-and-frozen/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,6 @@ | ||
{ | ||
"dependencies": { | ||
"left-pad": "1.1.3", | ||
"node.date-time": "1.2.2" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
.../fixtures/install/install-should-not-write-lockfile-if-not-optimized-and-frozen/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,17 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
[email protected]: | ||
version "1.1.3" | ||
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.1.3.tgz#612f61c033f3a9e08e939f1caebeea41b6f3199a" | ||
|
||
left-pad@^1.1.0: | ||
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.1.1.tgz#ca566bbdd84b90cc5969ac1726fda51f9d936a3c" | ||
|
||
[email protected]: | ||
version "1.2.2" | ||
resolved "https://registry.yarnpkg.com/node.date-time/-/node.date-time-1.2.2.tgz#2fc553b0520f1c75625b33fa5a1835c637ad9856" | ||
dependencies: | ||
left-pad "^1.1.0" |
Binary file added
BIN
+3.58 KB
...ures/request-cache/GET/registry.yarnpkg.com/node.date-time/-/node.date-time-1.2.2.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
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
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
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
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
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
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
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