Skip to content

Commit ba2971b

Browse files
committed
fix: run commands in package directory if meta=none
`project_dir` is set as the working directory if meta generation is turned off. Commands cwd to `project_dir`, so hooks will be run in whatever directory you're running the `generate` command in. The default post-hooks will then run recursively in that directory on any Python files it can find. Set the directory to run commands in to `package_dir` if meta is none, so post-hooks only touch the generated code. fixes openapi-generators#696
1 parent 47e576c commit ba2971b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

openapi_python_client/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ def _run_command(self, cmd: str) -> None:
153153
)
154154
return
155155
try:
156+
dir = self.package_dir if self.meta == MetaType.NONE else self.project_dir
156157
subprocess.run(
157-
cmd, cwd=self.project_dir, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True
158+
cmd, cwd=dir, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True
158159
)
159160
except CalledProcessError as err:
160161
self.errors.append(

0 commit comments

Comments
 (0)