Skip to content

Commit c3401de

Browse files
committed
feat: refactor utils confirm
1 parent 873c2c2 commit c3401de

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

lib/package.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export default class Package {
338338
if ( res.status ) {
339339
console.log( `Unable to publish to the npm registry` );
340340

341-
if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "yes" ) continue;
341+
if ( ( await confirm( "Repeat?", [ "[yes]", "no" ] ) ) === "yes" ) continue;
342342
}
343343

344344
break;
@@ -358,7 +358,7 @@ export default class Package {
358358
if ( res.status ) {
359359
console.log( `Unable to add tag "${ tag }"` );
360360

361-
if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "yes" ) continue;
361+
if ( ( await confirm( "Repeat?", [ "[yes]", "no" ] ) ) === "yes" ) continue;
362362
}
363363

364364
break;
@@ -380,7 +380,7 @@ export default class Package {
380380
if ( res.status ) {
381381
console.log( `Unable to remove tag "${ tag }"` );
382382

383-
if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "yes" ) continue;
383+
if ( ( await confirm( "Repeat?", [ "[yes]", "no" ] ) ) === "yes" ) continue;
384384
}
385385

386386
break;
@@ -874,9 +874,9 @@ export default class Package {
874874
if ( !install || !canUpdate ) return result( 200 );
875875

876876
if ( !yes ) {
877-
res = await confirm( "Update dependencies?", [ "no", "yes" ] );
877+
res = await confirm( "Update dependencies?", [ "yes", "[no]" ] );
878878

879-
if ( res === "no" ) return result( 200 );
879+
if ( res !== "yes" ) return result( 200 );
880880
}
881881

882882
// package dependencies are locked

lib/package/localization.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ ${ JSON.stringify( translatedMessage.translations, null, 4 ) }
271271
${ JSON.stringify( message.translations, null, 4 ) }
272272
` );
273273

274-
const answer = await utils.confirm( "What translations do you want to use?", [ "exit", "new", "old" ] );
274+
const answer = await utils.confirm( "What translations do you want to use?", [ "new", "old", "[cancel]" ] );
275275

276-
if ( answer === "exit" ) {
276+
if ( !answer || answer === "cancel" ) {
277277
process.exit( 1 );
278278
}
279279
else if ( answer === "new" ) {

lib/package/release.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default class Publish {
5959
if ( status.isDirty ) return result( [ 500, `working copy or sub-repositories has uncommited changes or untracked files` ] );
6060

6161
// check distance from the last release
62-
if ( status.currentVersion && !status.currentVersionDistance && ( await confirm( "No changes since the latest release. Continue?", [ "no", "yes" ] ) ) === "no" ) return result( [ 500, "Terminated" ] );
62+
if ( status.currentVersion && !status.currentVersionDistance && ( await confirm( "No changes since the latest release. Continue?", [ "yes", "[no]" ] ) ) !== "yes" ) return result( [ 500, "Terminated" ] );
6363

6464
this.#version = status.currentVersion;
6565

@@ -150,7 +150,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`,
150150
}
151151

152152
// confirm release
153-
if ( !this.#yes && ( await confirm( "Continue release process?", [ "no", "yes" ] ) ) === "no" ) return result( [ 500, "Terminated" ] );
153+
if ( !this.#yes && ( await confirm( "Continue release process?", [ "yes", "[no]" ] ) ) !== "yes" ) return result( [ 500, "Terminated" ] );
154154

155155
var res;
156156

@@ -200,7 +200,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`,
200200

201201
if ( res.ok ) break;
202202

203-
if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "no" ) return res;
203+
if ( ( await confirm( "Repeat?", [ "[yes]", "no" ] ) ) !== "yes" ) return res;
204204
}
205205

206206
// set version tag
@@ -213,7 +213,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`,
213213

214214
if ( res.ok ) break;
215215

216-
if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "no" ) return res;
216+
if ( ( await confirm( "Repeat?", [ "[yes]", "no" ] ) ) !== "yes" ) return res;
217217
}
218218

219219
// set "latest" tag
@@ -227,7 +227,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`,
227227

228228
if ( res.ok ) break;
229229

230-
if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "no" ) return res;
230+
if ( ( await confirm( "Repeat?", [ "[yes]", "no" ] ) ) !== "yes" ) return res;
231231
}
232232
}
233233

@@ -242,7 +242,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`,
242242

243243
if ( res.ok ) break;
244244

245-
if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "no" ) return res;
245+
if ( ( await confirm( "Repeat?", [ "[yes]", "no" ] ) ) !== "yes" ) return res;
246246
}
247247
}
248248

@@ -258,7 +258,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`,
258258
console.log( res + "" );
259259

260260
if ( !res.ok ) {
261-
if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "no" ) break;
261+
if ( ( await confirm( "Repeat?", [ "[yes]", "no" ] ) ) !== "yes" ) break;
262262
}
263263
else {
264264
break;
@@ -280,7 +280,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`,
280280
console.log( res + "" );
281281

282282
if ( !res.ok ) {
283-
if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "no" ) break;
283+
if ( ( await confirm( "Repeat?", [ "[yes]", "no" ] ) ) !== "yes" ) break;
284284
}
285285
else {
286286
break;
@@ -347,7 +347,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`,
347347
console.log( `\n${ ansi.hl( "# Changelog:" ) }\n\n${ log }` );
348348

349349
// confirm release
350-
if ( !this.#yes && ( await confirm( "Continue release process?", [ "no", "yes" ] ) ) === "no" ) return result( [ 500, "Terminated" ] );
350+
if ( !this.#yes && ( await confirm( "Continue release process?", [ "[yes]", "no" ] ) ) !== "yes" ) return result( [ 500, "Terminated" ] );
351351

352352
this.#changelog = log;
353353

0 commit comments

Comments
 (0)