diff --git a/src/scanner/Scanner.ts b/src/scanner/Scanner.ts index 52b1b3dbf..ed5d2f164 100644 --- a/src/scanner/Scanner.ts +++ b/src/scanner/Scanner.ts @@ -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)));