Skip to content

Commit 40e1519

Browse files
committed
Check if messages file already exists and replace it with the new file
1 parent 73c245e commit 40e1519

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Console/Commands/ExportMessages.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,17 @@ public function handle()
4848
$adapter = new Local( $filepath );
4949
$filesystem = new Filesystem( $adapter );
5050

51-
$contents = 'let messages = ' . json_encode( $messages );
51+
$contents = 'export default ' . json_encode( $messages );
5252

53-
$filesystem->write( $filename, $contents );
53+
if ( $filesystem->has( $filename ) ) {
54+
55+
$filesystem->delete( $filename );
56+
$filesystem->write( $filename, $contents );
57+
58+
} else {
59+
60+
$filesystem->write( $filename, $contents );
61+
}
5462

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

0 commit comments

Comments
 (0)