Skip to content

Commit 3b0ebad

Browse files
committed
Fix refresh-compile-command-bazel-module.py not works
1 parent 2181973 commit 3b0ebad

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

refresh-compile-command-bazel-module.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import pathlib
1919
import shutil
2020
import argparse
21-
from utils import run_shell_command_with_live_output
21+
import subprocess
2222

2323

2424
module_file_content = """
@@ -48,6 +48,16 @@ def _build_file_content(content, targets):
4848
4949
"""
5050

51+
def _run_shell_command_with_live_output(cmd, cwd, shell=True):
52+
print(cmd)
53+
p = subprocess.Popen(
54+
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd, shell=shell
55+
)
56+
for line in p.stdout:
57+
print(line.decode("utf-8").rstrip())
58+
p.wait()
59+
status = p.poll()
60+
assert status == 0
5161

5262
def _rm(path: str):
5363
p = pathlib.Path(path)
@@ -138,6 +148,6 @@ def __exit__(self, *args):
138148
bf.write(content)
139149

140150
# Run
141-
run_shell_command_with_live_output(
151+
_run_shell_command_with_live_output(
142152
'bazel run -s :refresh_compile_commands', cwd=os.getcwd(), shell=True
143153
)

0 commit comments

Comments
 (0)