1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4# Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 5# 6# HDF is dual licensed: you can use it either under the terms of 7# the GPL, or the BSD license, at your option. 8# See the LICENSE file in the root of this repository for complete details. 9import os 10import stat 11from asyncio import subprocess 12 13if __name__ == "__main__": 14 # development production 15 subprocess.run(["npx", "webpack", "--mode=development"]) 16 with open(r".\..\hcsVSCode\editor.html", "r", encoding="utf8") as file: 17 ss = file.read() 18 i1 = ss.index("// update js code begin") + len("// update js code begin") + 1 19 i2 = ss.index("// update js code end") - 1 20 with open(r".\dist\main.js", "r", encoding="utf8") as file: 21 destss = file.read() 22 ss = ss[:i1] + destss + ss[i2:] 23 flags = os.O_RDWR | os.O_CREAT 24 modes = stat.S_IWUSR | stat.S_IWGRP | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH 25 write_fd = os.open(r".\..\hcsVSCode\editor.html", flags, modes) 26 with os.fdopen(write_fd, "w", encoding="utf-8") as file: 27 file.write(ss) 28 print("replaced") 29