Skip to content

Commit

Permalink
test(docs-infra): expand select glob patterns in `verify-docs-codeown…
Browse files Browse the repository at this point in the history
…ership.js` (angular#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 angular#32360
  • Loading branch information
gkalpak authored and mhevery committed Aug 30, 2019
1 parent afc6ab5 commit c507e49
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions aio/scripts/verify-docs-codeownership.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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)).
Expand Down

0 comments on commit c507e49

Please sign in to comment.