Skip to content

Commit

Permalink
refactor(cache): Enable strict null checks (#15804)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
zharinov and viceice committed May 31, 2022
1 parent 4a3eec7 commit eab31ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 14 additions & 6 deletions lib/workers/repository/cache.ts
Expand Up @@ -28,20 +28,25 @@ function generateBranchUpgradeCache(
newDigest,
sourceUrl,
} = upgrade;
return {
const result: BranchUpgradeCache = {
datasource,
depName,
packageName,
fixedVersion,
currentVersion,
newVersion,
currentDigest,
newDigest,
sourceUrl,
};
if (packageName) {
result.packageName = packageName;
}
return result;
}

async function generateBranchCache(branch: BranchConfig): Promise<BranchCache> {
async function generateBranchCache(
branch: BranchConfig
): Promise<BranchCache | null> {
const { branchName } = branch;
try {
const sha = getBranchCommit(branchName) || null;
Expand Down Expand Up @@ -89,9 +94,12 @@ async function generateBranchCache(branch: BranchConfig): Promise<BranchCache> {
}

export async function setBranchCache(branches: BranchConfig[]): Promise<void> {
const branchCache: BranchCache[] = [];
const branchCaches: BranchCache[] = [];
for (const branch of branches) {
branchCache.push(await generateBranchCache(branch));
const branchCache = await generateBranchCache(branch);
if (branchCache) {
branchCaches.push(branchCache);
}
}
getCache().branches = branchCache.filter(Boolean);
getCache().branches = branchCaches;
}
2 changes: 0 additions & 2 deletions tsconfig.strict.json
Expand Up @@ -30,7 +30,6 @@
"lib/workers/global/config/parse/index.ts",
"lib/workers/global/index.ts",
"lib/workers/global/initialize.ts",
"lib/workers/repository/cache.ts",
"lib/workers/repository/changelog/index.ts",
"lib/workers/repository/error-config.ts",
"lib/workers/repository/error.ts",
Expand All @@ -41,7 +40,6 @@
"lib/workers/repository/finalise/prune.ts",
"lib/workers/repository/index.ts",
"lib/workers/repository/init/apis.ts",
"lib/workers/repository/init/cache.ts",
"lib/workers/repository/init/config.ts",
"lib/workers/repository/init/index.ts",
"lib/workers/repository/init/semantic.ts",
Expand Down

0 comments on commit eab31ff

Please sign in to comment.