* @param {Context} context
({ Yarn })
| 5 | * @param {Context} context |
| 6 | */ |
| 7 | function enforceConsistentDependenciesAcrossTheProject({ Yarn }) { |
| 8 | // check non-peer deps: |
| 9 | for (const dependency of Yarn.dependencies()) { |
| 10 | if (dependency.type === 'peerDependencies') continue |
| 11 | |
| 12 | for (const otherDependency of Yarn.dependencies({ ident: dependency.ident })) { |
| 13 | if (otherDependency.type === 'peerDependencies') continue |
| 14 | |
| 15 | dependency.update(otherDependency.range) |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | // check peer deps: |
| 20 | for (const dependency of Yarn.dependencies()) { |
| 21 | if (dependency.type !== 'peerDependencies') continue |
| 22 | |
| 23 | for (const otherDependency of Yarn.dependencies({ ident: dependency.ident })) { |
| 24 | if (otherDependency.type !== 'peerDependencies') continue |
| 25 | |
| 26 | dependency.update(otherDependency.range) |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | for (const workspace of Yarn.workspaces()) { |
| 31 | if (workspace.cwd === '.') continue |
| 32 | |
| 33 | workspace.set('packageManager', undefined) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Require a Node version where `require()` of an ES module works natively, so |
no test coverage detected
searching dependent graphs…