From f9bd03e11a6dfcfc57b4720bb0bc8c6832f0db05 Mon Sep 17 00:00:00 2001 From: Nils Haberkamp Date: Sun, 5 Nov 2023 13:32:27 +0000 Subject: [PATCH] define which directories to analyze --- src/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 184991d..0b20f65 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,12 +14,14 @@ import FileSorter from './core/sorting/FileSorter.js'; import DependencyCounter from './core/analysis/dependency/DependencyCounter.js'; const program = new Command() + .argument('', 'directories to analyze') .option('--webpack-config ', undefined) .option('--ts-config ', undefined); program.parse(process.argv); const options = program.opts(); +const args = program.args; // TODO: handle error const webpackConfig = options.webpackConfig @@ -36,10 +38,14 @@ const tsConfig = options.tsConfig (extractTSConfig(options.tsConfig) as TSConfig) : undefined; +const modifiedDirectoryPaths = args.map((path) => { + return path.replace(/^\.\//, '').replace(/\/$/, ''); +}); + const cruiseResult: IReporterOutput = await cruise( - ['src'], + modifiedDirectoryPaths, { - includeOnly: '^src', + includeOnly: modifiedDirectoryPaths.map((path) => `^${path}`), ruleSet: { // @ts-expect-error -- code works as expected typings of dependency-cruiser are wrong options: {