diff --git a/packages/analytics/src/cli.ts b/packages/analytics/src/cli.ts index ad3ad483d6..dcdccb04d0 100644 --- a/packages/analytics/src/cli.ts +++ b/packages/analytics/src/cli.ts @@ -16,7 +16,7 @@ export default async function cli(args: string[]) { .example('-o path/to/folder') .option('-c --config', 'Path to scanner config') .example('-c path/to/scanner.config.js') - .action(({ output, config, source }) => { + .action(async ({ output, config, source }) => { if (config && !fs.existsSync(config)) { errorMessage('Could not find config file'); process.exit(1); @@ -35,7 +35,8 @@ export default async function cli(args: string[]) { scanner({ source, outputPath: output, config }); infoMessage(`Start scanning: ${source}`); } else { - scanner({ source: ROOT_PATH, outputPath: output, config }); + const { default: loadedConfig } = await import(config); + scanner({ source: ROOT_PATH, outputPath: output, config: loadedConfig }); infoMessage('Start scanning from default scope'); } }) diff --git a/packages/analytics/src/runner.ts b/packages/analytics/src/runner.ts index 56facfd138..2d16337bd6 100644 --- a/packages/analytics/src/runner.ts +++ b/packages/analytics/src/runner.ts @@ -13,13 +13,13 @@ interface ProjectOutput { type Runner = (config: string, source: string) => ProjectOutput; -const getTrackedData = async ({ config, source }: { config: string; source: string }): ProjectOutput => { +const getTrackedData = async ({ config, source }: { config: unknown; source: string }): ProjectOutput => { const crawlFrom = path.resolve(source) || path.resolve(ROOT_PATH); const spiritVersion = await getVersions(crawlFrom); - const reactOutput = await reactScanner({ config, crawlFrom }); + const reactOutput = await reactScanner({ ...config, crawlFrom }); - const twigResult = await twigScanner({ config, crawlFrom }); + const twigResult = await twigScanner({ ...config, crawlFrom }); return { spiritVersion,