From 158e2d833440ed9ad08e3b0b76a078d0da04f247 Mon Sep 17 00:00:00 2001 From: zdm Date: Wed, 14 Feb 2024 20:48:12 +0200 Subject: [PATCH] fix: utils confirm --- lib/commands/git/install-hooks.js | 8 ++++---- lib/package.js | 6 +++--- lib/package/localization.js | 10 +++++----- lib/package/publish.js | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/commands/git/install-hooks.js b/lib/commands/git/install-hooks.js index 7cb1bc6b..d6351fb8 100644 --- a/lib/commands/git/install-hooks.js +++ b/lib/commands/git/install-hooks.js @@ -45,14 +45,14 @@ export default class extends Command { if ( !fs.existsSync( hooksPath.data ) ) fs.mkdirSync( hooksPath.data, { "recursive": true } ); // install pre-commit hook - if ( !fs.existsSync( hooksPath.data + "/pre-commit" ) || ( await utils.confirm( "Global pre-commit hook is already exists. Overwrite?", [ "n", "y" ] ) ) === "y" ) { + if ( !fs.existsSync( hooksPath.data + "/pre-commit" ) || ( await utils.confirm( "Global pre-commit hook is already exists. Overwrite?", [ "no", "yes" ] ) ) === "yes" ) { fs.copyFileSync( utils.resolve( "#resources/git-hooks/pre-commit", import.meta.url ), hooksPath.data + "/pre-commit" ); console.log( "Global git pre-commit hook installed." ); } // install commit-msg hook - if ( !fs.existsSync( hooksPath.data + "/commit-msg" ) || ( await utils.confirm( "Global commit-msg hook is already exists. Overwrite?", [ "n", "y" ] ) ) === "y" ) { + if ( !fs.existsSync( hooksPath.data + "/commit-msg" ) || ( await utils.confirm( "Global commit-msg hook is already exists. Overwrite?", [ "no", "yes" ] ) ) === "yes" ) { fs.copyFileSync( utils.resolve( "#resources/git-hooks/commit-msg", import.meta.url ), hooksPath.data + "/commit-msg" ); console.log( "Global git commit-msg hook installed." ); @@ -71,7 +71,7 @@ export default class extends Command { var installed; // install pre-commit hook - if ( !fs.existsSync( hooksPath + "/pre-commit" ) || ( await utils.confirm( "Local pre-commit hook is already exists. Overwrite?", [ "n", "y" ] ) ) === "y" ) { + if ( !fs.existsSync( hooksPath + "/pre-commit" ) || ( await utils.confirm( "Local pre-commit hook is already exists. Overwrite?", [ "no", "yes" ] ) ) === "yes" ) { fs.copyFileSync( utils.resolve( "#resources/git-hooks/pre-commit", import.meta.url ), hooksPath + "/pre-commit" ); console.log( "Local git pre-commit hook installed." ); @@ -80,7 +80,7 @@ export default class extends Command { } // install commit-msg hook - if ( !fs.existsSync( hooksPath + "/commit-msg" ) || ( await utils.confirm( "Local commit-msg hook is already exists. Overwrite?", [ "n", "y" ] ) ) === "y" ) { + if ( !fs.existsSync( hooksPath + "/commit-msg" ) || ( await utils.confirm( "Local commit-msg hook is already exists. Overwrite?", [ "no", "yes" ] ) ) === "yes" ) { fs.copyFileSync( utils.resolve( "#resources/git-hooks/commit-msg", import.meta.url ), hooksPath + "/commit-msg" ); installed = true; diff --git a/lib/package.js b/lib/package.js index 54fa5ef4..bada6d65 100644 --- a/lib/package.js +++ b/lib/package.js @@ -330,7 +330,7 @@ export default class Package { if ( res.status ) { console.log( `Unable to publish to the npm registry` ); - if ( ( await confirm( "Repeat?", [ "y", "n" ] ) ) === "y" ) continue; + if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "yes" ) continue; } break; @@ -350,7 +350,7 @@ export default class Package { if ( res.status ) { console.log( `Unable to add tag "${ tag }"` ); - if ( ( await confirm( "Repeat?", [ "y", "n" ] ) ) === "y" ) continue; + if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "yes" ) continue; } break; @@ -372,7 +372,7 @@ export default class Package { if ( res.status ) { console.log( `Unable to remove tag "${ tag }"` ); - if ( ( await confirm( "Repeat?", [ "y", "n" ] ) ) === "y" ) continue; + if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "yes" ) continue; } break; diff --git a/lib/package/localization.js b/lib/package/localization.js index 9334ee94..294188bb 100644 --- a/lib/package/localization.js +++ b/lib/package/localization.js @@ -290,9 +290,9 @@ ${ message.pluralId } Please, check thet plural forms for this message are the same in all your sources. ` ); - const answer = await utils.confirm( "Do you want to commit new plural form?", [ "n", "y" ] ); + const answer = await utils.confirm( "Do you want to commit new plural form?", [ "no", "yes" ] ); - if ( answer === "n" ) { + if ( answer === "no" ) { process.exit( 1 ); } else { @@ -317,12 +317,12 @@ ${ JSON.stringify( translatedMessage.translations, null, 4 ) } ${ JSON.stringify( message.translations, null, 4 ) } ` ); - const answer = await utils.confirm( "What translations do you want to use?", [ "e", "n", "o" ] ); + const answer = await utils.confirm( "What translations do you want to use?", [ "exit", "new", "old" ] ); - if ( answer === "e" ) { + if ( answer === "exit" ) { process.exit( 1 ); } - else if ( answer === "n" ) { + else if ( answer === "new" ) { if ( !message.pluralId ) { translatedMessage.translations[ 0 ] = message.translations[ 0 ]; } diff --git a/lib/package/publish.js b/lib/package/publish.js index 8a60cf25..71af60f2 100644 --- a/lib/package/publish.js +++ b/lib/package/publish.js @@ -56,7 +56,7 @@ export default class Publish { if ( status.isDirty ) return result( [ 500, `working copy or sub-repositories has uncommited changes or untracked files` ] ); // check distance from the last release - if ( status.currentVersion && !status.currentVersionDistance && ( await confirm( "No changes since the latest release. Continue?", [ "n", "y" ] ) ) === "n" ) return result( [ 500, "Terminated" ] ); + if ( status.currentVersion && !status.currentVersionDistance && ( await confirm( "No changes since the latest release. Continue?", [ "no", "yes" ] ) ) === "no" ) return result( [ 500, "Terminated" ] ); this.#version = status.currentVersion; @@ -173,7 +173,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`, } // confirm release - if ( !this.#force && ( await confirm( "Continue release process?", [ "n", "y" ] ) ) === "n" ) return result( [ 500, "Terminated" ] ); + if ( !this.#force && ( await confirm( "Continue release process?", [ "no", "yes" ] ) ) === "no" ) return result( [ 500, "Terminated" ] ); var res; @@ -251,7 +251,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`, console.log( res + "" ); if ( !res.ok ) { - if ( ( await confirm( "Repeat?", [ "y", "n" ] ) ) === "n" ) break; + if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "no" ) break; } else { break; @@ -273,7 +273,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`, console.log( res + "" ); if ( !res.ok ) { - if ( ( await confirm( "Repeat?", [ "y", "n" ] ) ) === "n" ) break; + if ( ( await confirm( "Repeat?", [ "yes", "no" ] ) ) === "no" ) break; } else { break; @@ -334,7 +334,7 @@ You need to merge with the "${ latestPreRelease.toVersionString() }" first.`, console.log( `\n${ ansi.hl( "# Changelog:" ) }\n\n${ log }` ); // confirm release - if ( !this.#force && ( await confirm( "Continue release process?", [ "n", "y" ] ) ) === "n" ) return result( [ 500, "Terminated" ] ); + if ( !this.#force && ( await confirm( "Continue release process?", [ "no", "yes" ] ) ) === "no" ) return result( [ 500, "Terminated" ] ); this.#changelog = log;