fix(js): handle when there are no package manager workspaces' patterns (#30666)

## Current Behavior

The helper to add a project to the package manager workspaces'
configuration doesn't handle correctly when there are no patterns and
this results in the error `Invalid glob pattern` being thrown.

## Expected Behavior

The helper to add a project to the package manager workspaces'
configuration should handle when there are no patterns.

## Related Issue(s)

Fixes #
This commit is contained in:
Leosvel Pérez Espinosa 2025-04-10 15:16:43 +02:00 committed by GitHub
parent 77e60c329f
commit 136e721d58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -230,7 +230,8 @@ export async function addProjectToTsSolutionWorkspace(
let pattern = projectDir;
if (baseDir !== '.') {
const patterns = getPackageManagerWorkspacesPatterns(tree);
const projectsBefore = await globAsync(tree, patterns);
const projectsBefore =
patterns.length > 0 ? await globAsync(tree, patterns) : [];
patterns.push(`${baseDir}/*/package.json`);
const projectsAfter = await globAsync(tree, patterns);