Skip to content

Commit

Permalink
feat: multiple version confirmation is supported
Browse files Browse the repository at this point in the history
  • Loading branch information
a145789 committed Mar 29, 2024
1 parent da71fc9 commit 319a7e9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ async function confirmVersion(currentVersion: string, expectVersion: string) {
const ret = await prompt([
{
name,
type: 'confirm',
message: `All packages version ${currentVersion} -> ${expectVersion}:`,
type: 'list',
choices: [`All packages version ${currentVersion} -> ${expectVersion}:`, 'back'],
},
])

Expand Down Expand Up @@ -189,13 +189,16 @@ export async function release(options: ReleaseCommandOptions) {
return
}

const type = await getReleaseType()
const isPreRelease = type.startsWith('pre')
let expectVersion = semver.inc(currentVersion, type, `alpha.${Date.now()}`) as string
expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion
let confirmVersionRet = 'back'
let isPreRelease = false
let expectVersion = ''
while (confirmVersionRet === 'back') {
const type = await getReleaseType()
isPreRelease = type.startsWith('pre')
expectVersion = semver.inc(currentVersion, type, `alpha.${Date.now()}`) as string
expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion

if (!(await confirmVersion(currentVersion, expectVersion))) {
return
confirmVersionRet = await confirmVersion(currentVersion, expectVersion)
}

updateVersion(expectVersion)
Expand Down

0 comments on commit 319a7e9

Please sign in to comment.