diff options
author | Sainnhe Park | 2024-03-02 12:32:43 +0800 |
---|---|---|
committer | Sainnhe Park | 2024-03-02 12:32:43 +0800 |
commit | 725958a7cb2f168923e8186820cfd496beb521c6 (patch) | |
tree | 23fbd132a0cbbcca80463108c8e54067f5835f9a | |
parent | 699e5689b217e475869fefe3b0da5fe33a8e3b01 (diff) | |
download | aur-725958a7cb2f168923e8186820cfd496beb521c6.tar.gz |
Add path checking
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 4 | ||||
-rwxr-xr-x | patch.py | 27 |
3 files changed, 27 insertions, 8 deletions
@@ -1,7 +1,7 @@ pkgbase = code-features-insiders pkgdesc = Unblock some features in Code OSS, including features in VSCode Insiders pkgver = 1.87.0 - pkgrel = 1 + pkgrel = 2 url = https://github.com/microsoft/vscode install = code-features-insiders.install arch = any @@ -16,7 +16,7 @@ pkgbase = code-features-insiders source = patch.py source = patch.json md5sums = a270718448070ecda3050b7569510105 - md5sums = f11f7ccd925de0398ef2e28b127bb063 + md5sums = 9ed6f3972479ab6d3d053e7c47ead55a md5sums = a17f01e570df18126948925f694ce4cd pkgname = code-features-insiders @@ -1,7 +1,7 @@ # Maintainer: Sainnhe Park <sainnhe@gmail.com> pkgname=code-features-insiders pkgver=1.87.0 -pkgrel=1 +pkgrel=2 pkgdesc='Unblock some features in Code OSS, including features in VSCode Insiders' arch=('any') url='https://github.com/microsoft/vscode' @@ -15,7 +15,7 @@ source=("${pkgname}.hook" 'patch.py' 'patch.json') md5sums=('a270718448070ecda3050b7569510105' - 'f11f7ccd925de0398ef2e28b127bb063' + '9ed6f3972479ab6d3d053e7c47ead55a' 'a17f01e570df18126948925f694ce4cd') package() { @@ -11,10 +11,27 @@ product_path = "/usr/lib/code/product.json" patch_path = "/usr/share/%s/patch.json" % pkt_name cache_path = "/usr/share/%s/cache.json" % pkt_name + +class term_colors: + WARNING = "\033[93m" + ENDC = "\033[0m" + + +if not os.path.exists(product_path): + print( + term_colors.WARNING + + "WARN: " + + term_colors.ENDC + + product_path + + " does not exist. You need to install extra/code in the official repository to use this package. Skipping..." + ) + exit(0) + if not os.path.exists(cache_path): - with open(cache_path, 'w') as file: + with open(cache_path, "w") as file: file.write("{}") + def patch(): with open(product_path, "r") as product_file: product_data = json.load(product_file) @@ -26,9 +43,10 @@ def patch(): cache_data[key] = product_data[key] product_data[key] = patch_data[key] with open(product_path, "w") as product_file: - json.dump(product_data, product_file, indent='\t') + json.dump(product_data, product_file, indent="\t") with open(cache_path, "w") as cache_file: - json.dump(cache_data, cache_file, indent='\t') + json.dump(cache_data, cache_file, indent="\t") + def restore(): with open(product_path, "r") as product_file: @@ -43,7 +61,8 @@ def restore(): for key in cache_data.keys(): product_data[key] = cache_data[key] with open(product_path, "w") as product_file: - json.dump(product_data, product_file, indent='\t') + json.dump(product_data, product_file, indent="\t") + if operation == "patch": patch() |