mirror of
https://github.com/BetterAndroid/compose-multiplatform-template.git
synced 2025-09-08 03:24:23 +08:00
fix: file encoding for windows and other os
This commit is contained in:
@@ -5,11 +5,11 @@ import json
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
def replace_strings_in_file(file_path, replacements):
|
def replace_strings_in_file(file_path, replacements):
|
||||||
with open(file_path, 'r') as file:
|
with open(file_path, 'r', encoding = 'utf-8') as file:
|
||||||
content = file.read()
|
content = file.read()
|
||||||
for key, value in replacements.items():
|
for key, value in replacements.items():
|
||||||
content = content.replace(key, value)
|
content = content.replace(key, value)
|
||||||
with open(file_path, 'w') as file:
|
with open(file_path, 'w', encoding = 'utf-8') as file:
|
||||||
file.write(content)
|
file.write(content)
|
||||||
|
|
||||||
def replace_strings_in_directory(directory, replacements, extensions):
|
def replace_strings_in_directory(directory, replacements, extensions):
|
||||||
@@ -20,7 +20,7 @@ def replace_strings_in_directory(directory, replacements, extensions):
|
|||||||
replace_strings_in_file(file_path, replacements)
|
replace_strings_in_file(file_path, replacements)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with open('initializer.json', 'r') as json_file:
|
with open('initializer.json', 'r', encoding = 'utf-8') as json_file:
|
||||||
replacements = json.load(json_file)
|
replacements = json.load(json_file)
|
||||||
extensions = ('.kt', '.properties', '.xml', '.gradle.kts', '.xcconfig', '.plist')
|
extensions = ('.kt', '.properties', '.xml', '.gradle.kts', '.xcconfig', '.plist')
|
||||||
replace_strings_in_directory('.', replacements, extensions)
|
replace_strings_in_directory('.', replacements, extensions)
|
||||||
|
Reference in New Issue
Block a user