dependency-cruiser 16.2.4-beta-1 → 16.2.4-beta-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -122,6 +122,16 @@ function isWebPackAliased(pModuleName, pAliasObject) {
|
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
function getWorkspacesArray(pManifestWorkspacesField) {
|
|
126
|
+
if (Array.isArray(pManifestWorkspacesField)) {
|
|
127
|
+
return pManifestWorkspacesField;
|
|
128
|
+
}
|
|
129
|
+
if (pManifestWorkspacesField?.packages) {
|
|
130
|
+
return pManifestWorkspacesField.packages;
|
|
131
|
+
}
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
|
|
125
135
|
/**
|
|
126
136
|
* @param {string} pModuleName
|
|
127
137
|
* @param {string} pResolvedModuleName
|
|
@@ -131,10 +141,11 @@ function isWebPackAliased(pModuleName, pAliasObject) {
|
|
|
131
141
|
// eslint-disable-next-line max-lines-per-function
|
|
132
142
|
function isWorkspaceAliased(pModuleName, pResolvedModuleName, pManifest) {
|
|
133
143
|
// reference: https://docs.npmjs.com/cli/v10/using-npm/workspaces
|
|
134
|
-
// for
|
|
144
|
+
// for yarn the workspaces field might be either an array or
|
|
135
145
|
// an object. To prevent the code from borking we check whether it's an array
|
|
136
146
|
// see https://github.com/sverweij/dependency-cruiser/issues/919
|
|
137
|
-
|
|
147
|
+
const lWorkspaces = getWorkspacesArray(pManifest?.workspaces);
|
|
148
|
+
if (lWorkspaces.length >= 0) {
|
|
138
149
|
// workspaces are an array of globs that match the (sub) workspace
|
|
139
150
|
// folder itself only.
|
|
140
151
|
//
|
|
@@ -157,9 +168,8 @@ function isWorkspaceAliased(pModuleName, pResolvedModuleName, pManifest) {
|
|
|
157
168
|
// oh and: ```picomatch.isMatch('asdf', 'asdf/**') === true``` so
|
|
158
169
|
// in case it's only 'asdf' that's in the resolved module name for some reason
|
|
159
170
|
// we're good as well.
|
|
160
|
-
const lModuleFriendlyWorkspaceGlobs =
|
|
161
|
-
(
|
|
162
|
-
pWorkspace.endsWith("/") ? `${pWorkspace}**` : `${pWorkspace}/**`,
|
|
171
|
+
const lModuleFriendlyWorkspaceGlobs = lWorkspaces.map((pWorkspace) =>
|
|
172
|
+
pWorkspace.endsWith("/") ? `${pWorkspace}**` : `${pWorkspace}/**`,
|
|
163
173
|
);
|
|
164
174
|
if (picomatch.isMatch(pResolvedModuleName, lModuleFriendlyWorkspaceGlobs)) {
|
|
165
175
|
return true;
|