Skip to content

Commit e63029a

Browse files
committed
fix(yarn): Do not fail for workspaces with interdependent packages
When a Yarn workspace project contains packages with a dependency inbetween, then it creates a symbolic link to the directories of the packages in the `node_module` directory during `yarn install`. In this case the directories returned by `findWorkspaceSubmodules()` point to these symbolic links instead of to the real file / directory. This results in `ModuleInfo.isProject` getting assigned to `false` for `pkg2`, which in turn leads to a `yarn info pkg2` call. As `pkg2` is not published, that call fails which in turn fails the entire analysis. Fix that by returning the real submodule directories, so that `isProject` is assigned correctly. Note: The dependency added to the `package.json` has to specify the version [1] in order to not run into a yarn issue. [1]: yarnpkg/yarn#4878 (comment) Signed-off-by: Frank Viernau <[email protected]>
1 parent d0c98aa commit e63029a

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

plugins/package-managers/node/src/funTest/assets/projects/synthetic/yarn/workspaces-expected-output.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ projects:
7575
dependencies:
7676
- id: "NPM::tr46:0.0.3"
7777
- id: "NPM::webidl-conversions:3.0.1"
78+
- id: "Yarn::pkg2:1.0.0"
79+
linkage: "PROJECT_DYNAMIC"
80+
dependencies:
81+
- id: "NPM:@here:harp-fetch:0.3.6"
82+
dependencies:
83+
- id: "NPM::node-fetch:2.7.0"
84+
dependencies:
85+
- id: "NPM::whatwg-url:5.0.0"
86+
dependencies:
87+
- id: "NPM::tr46:0.0.3"
88+
- id: "NPM::webidl-conversions:3.0.1"
7889
packages:
7990
- id: "NPM::node-fetch:2.7.0"
8091
purl: "pkg:npm/[email protected]"

plugins/package-managers/node/src/funTest/assets/projects/synthetic/yarn/workspaces/packages/pkg1/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"license": "Apache-2.0",
55
"dependencies": {
6-
"@here/harp-fetch": "^0.11.0"
6+
"@here/harp-fetch": "^0.11.0",
7+
"pkg2": "^1.0.0"
78
}
89
}

plugins/package-managers/node/src/main/kotlin/yarn/Yarn.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ open class Yarn(override val descriptor: PluginDescriptor = YarnFactory.descript
125125
dir.walk().maxDepth(1).filter {
126126
it.isDirectory && it.isSymbolicLink() && it != dir
127127
}
128-
}
128+
}.mapTo(mutableSetOf()) { it.realFile() }
129129
}
130130

131131
override fun beforeResolution(

0 commit comments

Comments
 (0)