Skip to content

Commit

Permalink
fix: filter error
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjiaxuan committed Feb 29, 2024
1 parent e425638 commit 9a3de43
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions src/command/bump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,36 @@ export async function bump(options: Option) {
})()

const bumpVersionMap = new Map<string, string>()
const pkgsJson = await Promise.all(bumpPackages.map(async (pkg) => {
const pkgJson = JSON.parse(await fsp.readFile(path.resolve(options.cwd, pkg), 'utf-8')) as { version?: string, name: string }
const currentVersion = pkgJson.version

if (!currentVersion)
return

let bumpVersion: string
if (rootBumpVersion) {
bumpVersion = rootBumpVersion
}
else if (bumpVersionMap.has(currentVersion)) {
bumpVersion = bumpVersionMap.get(currentVersion)!
}
else {
bumpVersion = semver.inc(currentVersion, bumpType.releaseType as ReleaseType, preid)!
bumpVersionMap.set(currentVersion, bumpVersion)
}

pkgJson.version = bumpVersion
return {
package: pkg,
currentVersion,
bumpVersion: pkgJson.version,
json: pkgJson,
jsonStr: JSON.stringify(pkgJson, null, 2),
}
}).filter(Boolean))
const pkgsJson = (await Promise.all(
bumpPackages.map(async (pkg) => {
const pkgJson = JSON.parse(await fsp.readFile(path.resolve(options.cwd, pkg), 'utf-8')) as { version?: string, name: string }
const currentVersion = pkgJson.version

if (!currentVersion)
return

let bumpVersion: string
if (rootBumpVersion) {
bumpVersion = rootBumpVersion
}
else if (bumpVersionMap.has(currentVersion)) {
bumpVersion = bumpVersionMap.get(currentVersion)!
}
else {
bumpVersion = semver.inc(currentVersion, bumpType.releaseType as ReleaseType, preid)!
bumpVersionMap.set(currentVersion, bumpVersion)
}

pkgJson.version = bumpVersion
return {
package: pkg,
currentVersion,
bumpVersion: pkgJson.version,
json: pkgJson,
jsonStr: JSON.stringify(pkgJson, null, 2),
}
}),
)).filter(Boolean)

if (isMonorepo)
console.log(pc.green(`Detect as a monorepo. Bump ${pc.bold(options.all ? 'all' : 'changed')}(${pkgsJson.length}) packages to ${pc.bold(`${bumpType.releaseType}${'preid' in bumpType ? `=${bumpType.preid}` : ''}`)}, ${bumpType.reason}:`))
Expand Down

0 comments on commit 9a3de43

Please sign in to comment.