Skip to content

Commit

Permalink
fix(npm): Types for bumpVersion parameter (#23717)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Aug 4, 2023
1 parent ae9b3af commit 0f872f8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/modules/manager/npm/update/package-version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ import { logger } from '../../../../../logger';
import { regEx } from '../../../../../util/regex';
import type { BumpPackageVersionResult } from '../../../types';

type MirrorBumpVersion = `mirror:${string}`;

function isMirrorBumpVersion(
bumpVersion: string
): bumpVersion is MirrorBumpVersion {
return bumpVersion.startsWith('mirror:');
}

export function bumpPackageVersion(
content: string,
currentValue: string,
bumpVersion: ReleaseType
bumpVersion: ReleaseType | `mirror:${string}`
): BumpPackageVersionResult {
logger.debug(
{ bumpVersion, currentValue },
Expand All @@ -16,7 +24,7 @@ export function bumpPackageVersion(
let newPjVersion: string | null;
let bumpedContent = content;
try {
if (bumpVersion.startsWith('mirror:')) {
if (isMirrorBumpVersion(bumpVersion)) {
const mirrorPackage = bumpVersion.replace('mirror:', '');
const parsedContent = JSON.parse(content);
newPjVersion =
Expand Down

0 comments on commit 0f872f8

Please sign in to comment.