Skip to content

Commit 73ab8c8

Browse files
committed
update: generate by script
1 parent ee9acf5 commit 73ab8c8

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@
262262
},
263263
"scripts": {
264264
"gen-blood": "ts-node ./src/snippets/source/blood/gen.ts",
265+
"gen-setup": "python3 ./src/commands/setup/create.py",
265266
"vscode:prepublish": "pnpm run package",
266267
"vscode:publish": "vsce package --no-dependencies",
267268
"compile": "webpack",

src/commands/setup/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
assets.ts

src/commands/setup/create.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
2-
import json
32
import base64
43

4+
55
def read_file_return_base64ed_content(filename):
66
data = ""
77
with open(filename, 'r') as f:
@@ -23,14 +23,24 @@ def create_value_map(filepath:str):
2323
variable_file_content_map.update(create_value_map(curr_file))
2424
return variable_file_content_map
2525

26+
dirname = os.path.dirname(__file__)
27+
output_file = open(dirname + "/assets.ts", "w")
28+
29+
def file_print(str):
30+
print(str, file=output_file)
31+
2632
def main():
27-
filepath = "."
28-
value_map = create_value_map(filepath)
29-
print("export let fs = {")
33+
file_print("// This file is auto-generated by create.py")
34+
file_print("// Do not edit this file directly")
35+
file_print("// Run `python src/commands/setup/create.py` to regenerate this file")
36+
value_map = create_value_map(dirname)
37+
file_print("export let fs = {")
3038
for key, value in value_map.items():
31-
print(f'\t"{key}": atob("{value}"),')
32-
print("};")
39+
file_print(f'\t"{key}": atob("{value}"),')
40+
file_print("};")
41+
print("Generated assets.ts successfully.")
3342

3443

3544
if __name__ == "__main__":
36-
main()
45+
main()
46+
output_file.close()

0 commit comments

Comments
 (0)