()
| 53 | |
| 54 | |
| 55 | def check_update(): |
| 56 | current_version = None |
| 57 | with open("./config.json", "r", encoding="utf-8") as f: |
| 58 | data = json.load(f) |
| 59 | current_version = data["nerd_font"]["version"] |
| 60 | |
| 61 | latest_version = current_version |
| 62 | print("Getting latest version from remote...") |
| 63 | with urlopen( |
| 64 | "https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest" |
| 65 | ) as response: |
| 66 | data = json.loads(response.read().decode("utf-8").split("\n")[0]) |
| 67 | for key in data: |
| 68 | if key == "tag_name": |
| 69 | latest_version = str(data[key])[1:] |
| 70 | break |
| 71 | |
| 72 | if latest_version == current_version: |
| 73 | print("✨ Current version match latest version") |
| 74 | if not check_font_patcher(latest_version): |
| 75 | print("Font-Patcher not exist and fail to download, exit") |
| 76 | exit(1) |
| 77 | return |
| 78 | |
| 79 | print( |
| 80 | f"Current version {current_version} not match latest version {latest_version}, update" |
| 81 | ) |
| 82 | if not check_font_patcher(latest_version, environ.get("GITHUB", "github.com")): |
| 83 | print("Fail to update Font-Patcher, exit") |
| 84 | exit(1) |
| 85 | update_config_json("./config.json", latest_version) |
| 86 | update_config_json("./source/preset-normal.json", latest_version) |
| 87 | |
| 88 | |
| 89 | def get_nerd_font_patcher_args(mono: bool, propo: bool = False): |
no test coverage detected