Repository navigation
fix: strip parenthetical comments from depends-on parser #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,10 +162,17 @@ export function parseWishGroups(content: string): GroupDefinition[] { | |
| let dependsOn: string[] = []; | ||
| if (depsMatch) { | ||
| const depsStr = depsMatch[1].trim(); | ||
| if (depsStr.toLowerCase() !== 'none') { | ||
| const depsNormalized = depsStr.replace(/\s*\([^)]*\)/g, '').trim(); | ||
| if (depsNormalized.toLowerCase() !== 'none') { | ||
| dependsOn = depsStr | ||
| .split(',') | ||
| .map((d) => d.trim().replace(/^group\s*/i, '')) | ||
| .map((d) => | ||
| d | ||
| .trim() | ||
| .replace(/^group\s*/i, '') | ||
| .replace(/\s*\(.*\)\s*$/, '') | ||
| .trim(), | ||
| ) | ||
| .filter(Boolean); | ||
| } | ||
|
Comment on lines
+165
to
177
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for stripping parenthetical comments is a bit convoluted. It first creates This is redundant and can be simplified by cleaning the dependency string once and using that cleaned string for all subsequent logic. This would make the code easier to read and maintain. const cleanedDepsStr = depsStr.replace(/\s*\([^)]*\)/g, '');
if (cleanedDepsStr.trim().toLowerCase() !== 'none') {
dependsOn = cleanedDepsStr
.split(',')
.map((d) =>
d
.trim()
.replace(/^group\s*/i, '')
.trim(),
)
.filter(Boolean);
} |
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a
depends-oncomment contains a comma (for exampleGroup 1 (setup, required), Group 2), this code splits on commas before removing parenthetical comments, so it produces invalid dependencies like"1 (setup"and"required)"instead of"1". That breaks dependency resolution instartGroupbecause those malformed IDs can never be satisfied. Removing parenthetical segments before.split(',')(or splitting only on commas outside parentheses) avoids corrupting the parsed dependency list.Useful? React with 👍 / 👎.