From c507e4907d0c90a6f0d7fa64588eda340d0ac8db Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Wed, 28 Aug 2019 10:13:57 +0300 Subject: [PATCH] test(docs-infra): expand select glob patterns in `verify-docs-codeownership.js` (#32360) This allows the script to recognise some matches that it would miss before and avoid listing them as missing. Ideally, the script should be able to understand the globs in `CODEOWNERS` and correctly find matching file-system paths.However, for the limited purposes of the script (and for just a couple of relevant globs), implementing this would be an overkill. Implemented the "manual expansion" instead. (We might revisit, if the needs change.) PR Close #32360 --- aio/scripts/verify-docs-codeownership.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/aio/scripts/verify-docs-codeownership.js b/aio/scripts/verify-docs-codeownership.js index 4b36b3b136..7947165252 100644 --- a/aio/scripts/verify-docs-codeownership.js +++ b/aio/scripts/verify-docs-codeownership.js @@ -71,6 +71,11 @@ function getPathsFromCodeowners() { // different kinds of matches (guide, image, example) later (see `isImage`/`isExample` below). const aioGuidesOrImagesPathRe = /^\/aio\/content\/(?:(images\/)?guide|(examples))\/([^\s\*/]+)/; const pkgExamplesPathRe = /^\/packages\/examples\/([^\s\*/]+)/; + const manualGlobExpansions = { + // `CODEOWNERS` has a glob to match all `testing/` directories, so no specific glob for + // `packages/examples/testing/` is necessary. + 'testing/**': ['/packages/examples/testing/**'], + }; const aioGuides = []; const aioImages = []; @@ -83,6 +88,14 @@ function getPathsFromCodeowners() { split('\n'). map(l => l.trim()); + // Manually expand globs to known matching patterns. + for (const [glob, expansions] of Object.entries(manualGlobExpansions)) { + const matchingLine = lines.find(l => l.startsWith(`${glob} `)); + if (matchingLine !== undefined) { + lines.push(...expansions); + } + } + // Collect `aio/` guides/images/examples. lines. map(l => l.match(aioGuidesOrImagesPathRe)).