Skip to content

Commit

Permalink
Check if messages file already exists and replace it with the new file
Browse files Browse the repository at this point in the history
  • Loading branch information
kg-bot committed Jul 25, 2018
1 parent 73c245e commit 40e1519
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Console/Commands/ExportMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ public function handle()
$adapter = new Local( $filepath );
$filesystem = new Filesystem( $adapter );

$contents = 'let messages = ' . json_encode( $messages );
$contents = 'export default ' . json_encode( $messages );

$filesystem->write( $filename, $contents );
if ( $filesystem->has( $filename ) ) {

$filesystem->delete( $filename );
$filesystem->write( $filename, $contents );

} else {

$filesystem->write( $filename, $contents );
}

$this->info( 'Messages exported to JavaScript file, you can find them at ' . $filepath . DIRECTORY_SEPARATOR
. $filename );
Expand Down

0 comments on commit 40e1519

Please sign in to comment.