Skip to content

Commit

Permalink
refactor(autoreplace): extractPackageFile (#20660)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins authored Feb 28, 2023
1 parent 456a8da commit 5419634
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/workers/repository/update/branch/auto-replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import is from '@sindresorhus/is';
import { WORKER_FILE_UPDATE_FAILED } from '../../../../constants/error-messages';
import { logger } from '../../../../logger';
import { get } from '../../../../modules/manager';
import { extractPackageFile } from '../../../../modules/manager';
import type { PackageDependency } from '../../../../modules/manager/types';
import { writeLocalFile } from '../../../../util/fs';
import { escapeRegExp, regEx } from '../../../../util/regex';
Expand All @@ -23,12 +23,12 @@ export async function confirmIfDepUpdated(
currentDigest,
pinDigests,
} = upgrade;
const extractPackageFile = get(manager, 'extractPackageFile');
let newUpgrade: PackageDependency;
try {
const newExtract = await extractPackageFile!(
const newExtract = await extractPackageFile(
manager,
newContent,
packageFile,
packageFile!,
upgrade
);
// istanbul ignore if
Expand Down Expand Up @@ -104,9 +104,13 @@ export async function checkBranchDepsMatchBaseDeps(
branchContent: string
): Promise<boolean> {
const { baseDeps, manager, packageFile } = upgrade;
const extractPackageFile = get(manager, 'extractPackageFile');
try {
const res = await extractPackageFile!(branchContent, packageFile, upgrade)!;
const res = await extractPackageFile(
manager,
branchContent,
packageFile!,
upgrade
)!;
const branchDeps = res!.deps;
return getDepsSignature(baseDeps!) === getDepsSignature(branchDeps);
} catch (err) /* istanbul ignore next */ {
Expand Down

0 comments on commit 5419634

Please sign in to comment.