Skip to content

Commit f64e5f5

Browse files
committed
refactor(cmd): replace subprocess.Popen with run
1 parent 0032547 commit f64e5f5

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

commitizen/cmd.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,11 @@ def _try_decode(bytes_: bytes) -> str:
3838
def run(cmd: str, env: Mapping[str, str] | None = None) -> Command:
3939
if env is not None:
4040
env = {**os.environ, **env}
41-
process = subprocess.Popen(
42-
cmd,
43-
shell=True,
44-
stdout=subprocess.PIPE,
45-
stderr=subprocess.PIPE,
46-
stdin=subprocess.PIPE,
47-
env=env,
48-
)
49-
stdout, stderr = process.communicate()
50-
return_code = process.returncode
41+
c = subprocess.run([cmd], shell=True, capture_output=True, env=env)
5142
return Command(
52-
_try_decode(stdout),
53-
_try_decode(stderr),
54-
stdout,
55-
stderr,
56-
return_code,
43+
_try_decode(c.stdout),
44+
_try_decode(c.stderr),
45+
c.stdout,
46+
c.stderr,
47+
c.returncode,
5748
)

0 commit comments

Comments
 (0)