Skip to content

Commit 13dfad9

Browse files
committed
a few changes
1 parent e293f47 commit 13dfad9

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

pydantic2ts/cli/script.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,23 +207,15 @@ def generate_typescript_defs(
207207

208208
logger.info("Generating JSON schema from pydantic models...")
209209

210-
schema = _generate_json_schema(models)
211210
schema_dir = Path(mkdtemp())
212-
schema_file_path = schema_dir.joinpath("schema.json")
213-
schema_file_path.write_text(schema)
211+
schema_file = schema_dir.joinpath("schema.json")
212+
schema_file.write_text(_generate_json_schema(models))
214213

215214
logger.info("Converting JSON schema to typescript definitions...")
216215

217216
json2ts_result = subprocess.run(
218-
[
219-
*shlex.split(json2ts_cmd),
220-
"-i",
221-
schema_file_path,
222-
"-o",
223-
output,
224-
"--banner-comment",
225-
"",
226-
]
217+
f'{json2ts_cmd} -i {str(schema_file)} -o {output} --bannerComment ""',
218+
shell=True,
227219
)
228220

229221
shutil.rmtree(schema_dir)
@@ -243,7 +235,7 @@ def _parse_cli_args(args: List[str] = None) -> argparse.Namespace:
243235
"""
244236
parser = argparse.ArgumentParser(
245237
prog="pydantic2ts",
246-
description=_main.__doc__,
238+
description=main.__doc__,
247239
formatter_class=argparse.RawTextHelpFormatter,
248240
)
249241
parser.add_argument(
@@ -273,7 +265,7 @@ def _parse_cli_args(args: List[str] = None) -> argparse.Namespace:
273265
return parser.parse_args(args)
274266

275267

276-
def _main() -> None:
268+
def main() -> None:
277269
"""
278270
CLI entrypoint to run :func:`generate_typescript_defs`
279271
"""
@@ -288,4 +280,4 @@ def _main() -> None:
288280

289281

290282
if __name__ == "__main__":
291-
_main()
283+
main()

0 commit comments

Comments
 (0)