Skip to content

Commit

Permalink
fix: utils confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Feb 14, 2024
1 parent c8c2464 commit 158e2d8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions lib/commands/git/install-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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." );
Expand All @@ -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." );
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions lib/package/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 ];
}
Expand Down
10 changes: 5 additions & 5 deletions lib/package/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 158e2d8

Please sign in to comment.