Skip to content

Commit dcb7af2

Browse files
committed
Fixed subprocess output handling
Updated the node version check to properly handle the fact that subprocess.check_output() returns bytes in Python 3, not strings. Added code to decode bytes to UTF-8 string and strip whitespace before checking the version.
1 parent 85fc052 commit dcb7af2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

build-script-helper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def ensure_npm_is_installed(verbose=False):
7373
fatal_error('-- Error: %s' % error_msg)
7474
try:
7575
node_version = check_output(['node', '--version'], verbose=verbose)
76-
if not node_version.startswith('v18.16.'):
76+
# Ensure node_version is a string (decode if it's bytes)
77+
if isinstance(node_version, bytes):
78+
node_version = node_version.decode('utf-8')
79+
if not node_version.strip().startswith('v18.16.'):
7780
warn_msg = "Unexpected version of 'node' installed. Swift-DocC-Render requires node 18.16.1. "\
7881
"See the README.md file for more information about building Swift-DocC-Render."
7982
printerr('-- Warning: %s' % warn_msg)

0 commit comments

Comments
 (0)