Skip to content

Commit

Permalink
fix: scan recursively if found 0 components in a root path
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopsimek committed Oct 31, 2019
1 parent e53e067 commit 3801970
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/scanner/Scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,18 @@ export class Scanner {
let relevantComponents = componentsWithContext;

// run only for root component if not set explicitly to run recursively

if (!this.argumentsProvider.recursive && relevantComponents.length > 1) {
const componentsSharedPath = sharedSubpath(relevantComponents.map((cwc) => cwc.component.path));
relevantComponents = relevantComponents.filter((cwc) => cwc.component.path === componentsSharedPath);
cli.info(
`Found more than 1 component. To scan all ${componentsWithContext.length} components run the scanner with an argument --recursive`,
);
const componentsAtRootPath = relevantComponents.filter((cwc) => cwc.component.path === componentsSharedPath);

// do not scan only root path if found 0 components there
if (componentsAtRootPath.length > 0) {
relevantComponents = componentsAtRootPath;
cli.info(
`Found more than 1 component. To scan all ${componentsWithContext.length} components run the scanner with an argument --recursive`,
);
}
}

const practicesWithComponentContext = await Promise.all(relevantComponents.map((cwctx) => this.detectPracticesForComponent(cwctx)));
Expand Down

0 comments on commit 3801970

Please sign in to comment.