Skip to content

Commit

Permalink
Deduplicate workspace names (#391)
Browse files Browse the repository at this point in the history
It is possible that the manifest workspaces include the root workspace.
In this case `ConfigurationChie#getAvailableWorkspaceName()` would
return the root name twice. This in turn would result in the root
package being included twice and throw a `ConfigurationError` because of
a duplicate package name.

To address this we deduplicate the workspace names.

Fixes #390
  • Loading branch information
geigerzaehler authored Dec 12, 2023
1 parent fdc65ef commit 28d43bb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/knip/src/ConfigurationChief.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ export class ConfigurationChief {
}

private getAvailableWorkspaceNames() {
return [ROOT_WORKSPACE_NAME, ...this.manifestWorkspaces.keys(), ...this.additionalWorkspaceNames].filter(
name => !micromatch.isMatch(name, this.ignoredWorkspacePatterns)
);
return [
...new Set([ROOT_WORKSPACE_NAME, ...this.manifestWorkspaces.keys(), ...this.additionalWorkspaceNames]),
].filter(name => !micromatch.isMatch(name, this.ignoredWorkspacePatterns));
}

private getAvailableWorkspaceManifests(availableWorkspaceDirs: string[]) {
Expand Down

0 comments on commit 28d43bb

Please sign in to comment.