Skip to content

Commit

Permalink
fix: node.js debugger adds stderr (but exit code is 0) -> shouldn't t…
Browse files Browse the repository at this point in the history
…hrow (#2719)

* fix: node.js debugger adds stderr (but exit code is 0) -> shouldn't throw

* input.py: subprocess.Popen() -> subprocess.run()
  • Loading branch information
FuPeiJiang committed Aug 22, 2022
1 parent 8958ecf commit c379a74
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions gyp/pylib/gyp/input.py
Expand Up @@ -961,33 +961,26 @@ def ExpandVariables(input, phase, variables, build_file):
# Fix up command with platform specific workarounds.
contents = FixupPlatformCommand(contents)
try:
p = subprocess.Popen(
# stderr will be printed no matter what
result = subprocess.run(
contents,
shell=use_shell,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
shell=use_shell,
cwd=build_file_dir,
check=False
)
except Exception as e:
raise GypError(
"%s while executing command '%s' in %s"
% (e, contents, build_file)
)

p_stdout, p_stderr = p.communicate("")
p_stdout = p_stdout.decode("utf-8")
p_stderr = p_stderr.decode("utf-8")

if p.wait() != 0 or p_stderr:
sys.stderr.write(p_stderr)
# Simulate check_call behavior, since check_call only exists
# in python 2.5 and later.
if result.returncode > 0:
raise GypError(
"Call to '%s' returned exit status %d while in %s."
% (contents, p.returncode, build_file)
% (contents, result.returncode, build_file)
)
replacement = p_stdout.rstrip()
replacement = result.stdout.decode("utf-8").rstrip()

cached_command_results[cache_key] = replacement
else:
Expand Down

0 comments on commit c379a74

Please sign in to comment.