Skip to content

Commit

Permalink
fix some code styling comment
Browse files Browse the repository at this point in the history
  • Loading branch information
cjtim committed Apr 19, 2023
1 parent b30d16b commit c228d14
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions lib/modules/manager/sbt/extract.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import upath from 'upath';
import { logger } from '../../../logger';
import { readLocalFile } from '../../../util/fs';
import { newlineRegex, regEx } from '../../../util/regex';
Expand Down Expand Up @@ -493,7 +494,6 @@ export function extractFile(
}

function prepareLoadPackageFiles(
_config: ExtractConfig,
packageFilesContent: { packageFile: string; content: string }[]
): {
globalVariables: ParseOptions['variables'];
Expand Down Expand Up @@ -540,34 +540,26 @@ export async function extractAllPackageFiles(
const groupPackageFileContent: GroupFilenameContent = {};
for (const packageFile of packageFiles) {
const content = await readLocalFile(packageFile, 'utf8');
if (!content) {
logger.trace({ packageFile }, 'packageFile has no content');
continue;
}
const paths = packageFile.split('/');
const group = paths.length > 1 ? paths[0] : '';
if (!groupPackageFileContent[group]) {
groupPackageFileContent[group] = [];
if (content) {
const group = upath.dirname(packageFile);
groupPackageFileContent[group] ??= [];
groupPackageFileContent[group].push({ packageFile, content });
}
groupPackageFileContent[group].push({ packageFile, content });
logger.trace({ packageFile }, 'packageFile has no content');
}

// 1. globalVariables from project/ and root package file
// 2. registry from all package file
// 3. Project's scalaVersion - use in parseDepExpr to add suffix eg. "_2.13"
const { globalVariables, registryUrls, scalaVersion } =
prepareLoadPackageFiles(_config, [
...(groupPackageFileContent['project']
? groupPackageFileContent['project']
: []), // in project/ folder
...(groupPackageFileContent[''] ? groupPackageFileContent[''] : []), // root
prepareLoadPackageFiles([
...(groupPackageFileContent['project'] ?? []), // in project/ folder
...(groupPackageFileContent['.'] ?? []), // root
]);

const mapDepsToPackageFile: Record<string, PackageDependency[]> = {};
// Start extract all package files
for (const [, packageFileContents] of Object.entries(
groupPackageFileContent
)) {
for (const packageFileContents of Object.values(groupPackageFileContent)) {
// Extract package file by its group
// local variable is share within its group
for (const { packageFile, content } of packageFileContents) {
Expand Down Expand Up @@ -610,5 +602,5 @@ export async function extractAllPackageFiles(
})
);

return formatedDeps.length > 0 ? formatedDeps : null;
return formatedDeps.length ? formatedDeps : null;
}

0 comments on commit c228d14

Please sign in to comment.