Skip to content

Commit

Permalink
Merge pull request #72 from jahusa02/bugfix/logs
Browse files Browse the repository at this point in the history
fix: update log formatting in utils to display dependency names
  • Loading branch information
koliveira15 authored Feb 14, 2024
2 parents 99a070a + 484da44 commit 2ee0028
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions packages/nx-sonarqube/src/executors/scan/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ function getCoverageDirectoryName(executor: Executor): CoverageDirectoryName {
return 'coverageDirectory';
}


export async function determinePaths(
options: ScanExecutorSchema,
context: ExecutorContext
Expand All @@ -94,7 +93,8 @@ export async function determinePaths(

if (dep.testTarget) {
const executor: Executor = getExecutor(dep.testTarget.executor);
const coverageDirectoryName: CoverageDirectoryName = getCoverageDirectoryName(executor);
const coverageDirectoryName: CoverageDirectoryName =
getCoverageDirectoryName(executor);

if (dep.testTarget.options?.[coverageDirectoryName]) {
lcovPaths.push(
Expand All @@ -105,7 +105,10 @@ export async function determinePaths(
'lcov.info'
)
);
} else if (executor === '@nx/jest:jest' && dep.testTarget.options?.jestConfig) {
} else if (
executor === '@nx/jest:jest' &&
dep.testTarget.options?.jestConfig
) {
const jestConfigPath = dep.testTarget.options.jestConfig;
const jestConfig = readFileSync(jestConfigPath, 'utf-8');
const ast = tsquery.ast(jestConfig);
Expand All @@ -127,15 +130,18 @@ export async function determinePaths(
);
} else {
logger.warn(
`Skipping ${context.projectName} as it does not have a coverageDirectory in ${jestConfigPath}`
`Skipping ${dep.name} as it does not have a coverageDirectory in ${jestConfigPath}`
);
}
} else if (executor === '@nx/vite:test') {
const configPath: string | undefined = getViteConfigPath(context.root, dep);
const configPath: string | undefined = getViteConfigPath(
context.root,
dep
);

if (configPath === undefined) {
logger.warn(
`Skipping ${context.projectName} as we cannot find a vite config file`
`Skipping ${dep.name} as we cannot find a vite config file`
);

return;
Expand All @@ -161,18 +167,14 @@ export async function determinePaths(
);
} else {
logger.warn(
`Skipping ${context.projectName} as it does not have a reportsDirectory in ${configPath}`
`Skipping ${dep.name} as it does not have a reportsDirectory in ${configPath}`
);
}
} else {
logger.warn(
`Skipping ${context.projectName} as it does not have a jestConfig`
);
logger.warn(`Skipping ${dep.name} as it does not have a jestConfig`);
}
} else {
logger.warn(
`Skipping ${context.projectName} as it does not have a test target`
);
logger.warn(`Skipping ${dep.name} as it does not have a test target`);
}
});

Expand Down Expand Up @@ -305,7 +307,9 @@ function getPackageJsonVersion(dir = ''): string {
`resolved package json from ${dir}, package version:${version}`
);
} catch (e) {
logger.debug(`Unable to open file ${joinPathFragments(dir, 'package.json')}`)
logger.debug(
`Unable to open file ${joinPathFragments(dir, 'package.json')}`
);
}
return version;
}
Expand Down Expand Up @@ -346,10 +350,10 @@ export function normalizeViteConfigFilePathWithTree(
return configFilePath && existsSync(configFilePath)
? configFilePath
: existsSync(joinPathFragments(`${projectRoot}/vite.config.ts`))
? joinPathFragments(`${projectRoot}/vite.config.ts`)
: existsSync(joinPathFragments(`${projectRoot}/vite.config.js`))
? joinPathFragments(`${projectRoot}/vite.config.js`)
: undefined;
? joinPathFragments(`${projectRoot}/vite.config.ts`)
: existsSync(joinPathFragments(`${projectRoot}/vite.config.js`))
? joinPathFragments(`${projectRoot}/vite.config.js`)
: undefined;
}

export function getViteConfigPath(
Expand Down

0 comments on commit 2ee0028

Please sign in to comment.