Fix: strip inline YAML comments when reading pnpm workspace globs (#570)

An inline comment on a pnpm-workspace.yaml packages line defeated the
end-anchored flow-list regex and the block-list state switch, so
workspaces outside apps/ or packages/ went unrecognized. Reuses the
engine's existing stripInlineYamlComment, matching context.mjs.

Written with AI assistance (Cursor); reviewed by maintainer.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Abdul Wahab
2026-08-14 23:47:59 +05:00
co-authored by Cursor
parent dca8f1ca6f
commit 91f2c7b47e
2 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -603,7 +603,7 @@ function readWorkspacePatterns(dir) {
try {
let inPackages = false;
for (const line of fs.readFileSync(path.join(dir, 'pnpm-workspace.yaml'), 'utf-8').split(/\r?\n/)) {
const trimmed = line.trim();
const trimmed = stripInlineYamlComment(line).trim();
if (!trimmed || trimmed.startsWith('#')) continue;
const flow = trimmed.match(/^packages:\s*\[(.*)\]\s*$/);
if (flow) {
+17
View File
@@ -117,6 +117,23 @@ describe('detect CLI monorepo DESIGN.md inheritance', () => {
);
});
it('pnpm flow list with inline comment and non-standard dirs still detected', () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'impeccable-detect-mono-flow-'));
tempRoots.push(dir);
fs.writeFileSync(path.join(dir, 'DESIGN.md'), DESIGN_MD);
fs.writeFileSync(path.join(dir, 'pnpm-workspace.yaml'), 'packages: ["services/*"] # deploy targets\n');
fs.mkdirSync(path.join(dir, 'services/api'), { recursive: true });
fs.writeFileSync(path.join(dir, 'services/api/package.json'), '{"name":"api"}');
const page = path.join(dir, 'services/api/page.html');
fs.writeFileSync(page, PAGE_HTML);
const findings = runDetect(dir, [page]);
assert.ok(
fontFindingsFor(findings, page).some((f) => f.ignoreValue === 'verdana'),
'inline YAML comment must not defeat workspace-glob recognition',
);
});
it('directory target: scan apps/web dir inherits root DESIGN.md', () => {
const { dir, page, webDir } = mkPnpmMonorepo();
const findings = runDetect(dir, [webDir]);