forked from zen-browser/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_ts_types.py
More file actions
53 lines (44 loc) · 1.5 KB
/
update_ts_types.py
File metadata and controls
53 lines (44 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
FILES = [
"index.d.ts",
"lib.gecko.tweaks.d.ts",
"lib.gecko.xpidl.d.ts",
]
GENERATED_FILES = [
"lib.gecko.win32.d.ts",
"lib.gecko.xpcom.d.ts",
"lib.gecko.darwin.d.ts",
"lib.gecko.dom.d.ts",
"lib.gecko.glean.d.ts",
"lib.gecko.linux.d.ts",
"lib.gecko.modules.d.ts",
"lib.gecko.nsresult.d.ts",
"lib.gecko.services.d.ts",
]
ENGINE_PATH = os.path.join("engine", "tools", "@types")
GENERATED_PATH = os.path.join(ENGINE_PATH, "generated")
SRC_PATH = os.path.join("src", "zen", "@types")
def update_ts_types():
os.system("cd engine && ./mach ts build && ./mach ts update")
# copy the files from engine/tools/@types to src/@types
for file in FILES + GENERATED_FILES:
if file in GENERATED_FILES:
src_file = os.path.join(GENERATED_PATH, file)
else:
src_file = os.path.join(ENGINE_PATH, file)
dest_file = os.path.join(SRC_PATH, file)
if os.path.exists(src_file):
os.system(f"cp {src_file} {dest_file}")
else:
print(f"File {src_file} does not exist.")
# add zen.d.ts to the end of index.d.ts
with open(os.path.join(SRC_PATH, "index.d.ts"), "a") as f:
f.write("\n")
f.write('/// <reference types="./zen.d.ts" />\n')
f.write('\n')
if __name__ == "__main__":
update_ts_types()
print("Updated TypeScript types.")