Skip to content

Commit

Permalink
refactor: remove unnecessary confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonTheAdams committed Jan 5, 2023
1 parent 52415dd commit 5af8236
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions bin/set-domain
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,10 @@ function ask( string $question, string $default = '' ): string {
return $answer;
}

function confirm( string $question, bool $default = false ): bool {
$answer = ask( $question . ' (' . ( $default ? 'Y/n' : 'y/N' ) . ')' );

if ( ! $answer ) {
return $default;
}

return strtolower( $answer ) === 'y';
}

function replace_in_file( string $file, array $replacements ) {
$contents = file_get_contents( $file );

$success = file_put_contents(
file_put_contents(
$file,
str_replace(
array_keys( $replacements ),
Expand All @@ -51,10 +41,6 @@ if ( empty( $domain ) ) {
exit( 0 );
}

if ( ! confirm( 'Modify files?', true ) ) {
exit( 1 );
}

$files = explode( PHP_EOL, run( 'grep -E -r -l -i "%TEXTDOMAIN%" ' . dirname( __FILE__, 2 ) . '/src' ) );
$files = array_filter( $files );

Expand Down

0 comments on commit 5af8236

Please sign in to comment.