Skip to content

Commit 5ac771b

Browse files
fix the script with subprocess
1 parent 43bb059 commit 5ac771b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/build_twilio_library.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import glob
23
import json
34
import os
45
import re
@@ -83,7 +84,7 @@ def generate(spec_folder: str, spec_files: List[str], output_path: str, language
8384

8485

8586
def generate_domain_for_language(spec_file: str, config_path: str, spec_folder: str, output_path: str, language: str, parent_dir: str) -> None:
86-
print("generate domain for language: {}, config: {}, spec file: {}".format(language, config_path, spec_file))
87+
print("generate domain for language: {}, config: {}, spec folder: {}, file: {}".format(language, config_path, spec_folder, spec_file))
8788
full_path = os.path.join(spec_folder, spec_file)
8889
full_config_path = os.path.join(config_path, spec_file)
8990
config = {
@@ -96,21 +97,23 @@ def generate_domain_for_language(spec_file: str, config_path: str, spec_folder:
9697
}
9798
# print(config)
9899
with open(full_config_path, 'w') as f:
99-
f.write(json.dumps(config))
100+
f.write(json.dumps(config) + "\n")
100101

101102
def run_openapi_generator(parent_dir: Path, language: str) -> None:
102103
properties = "-DapiTests=false"
103104
if language in {"node", "python"}:
104105
properties += " -DskipFormModel=false"
105106

107+
paths = glob.glob(os.path.join(CONFIG_FOLDER, language, "*"))
108+
106109
command = [
107110
"java",
108111
*properties.split(), # Splits e.g. "-DapiTests=false -DskipFormModel=false" into separate arguments
109112
"-cp",
110113
"target/twilio-openapi-generator.jar",
111114
"org.openapitools.codegen.OpenAPIGenerator",
112115
"batch",
113-
f"{CONFIG_FOLDER}/{language}/*"
116+
*paths,
114117
]
115118

116119
printable_cmd = " ".join(shlex.quote(arg) for arg in command)

0 commit comments

Comments
 (0)