Skip to content

Commit 657678a

Browse files
committed
Merge pull request #330 from hoanhtien/versionCheckMacOs
On Linux/MacOS, command passed to subprocess.check_output should be a string rather than a list
2 parents 1787173 + 91ac82d commit 657678a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,19 @@ def _get_plugin_tsc_version():
141141
cmd = [get_node_path(), TSC_PATH, "-v"]
142142
return _execute_cmd_and_parse_version_from_output(cmd)
143143

144+
def _is_executable(path):
145+
return os.path.isfile(path) and os.access(path, os.X_OK)
146+
144147
def _get_npm_tsc_version():
145-
cmd = ["tsc", "-v"]
148+
if os.name != 'nt' and _is_executable("/usr/local/bin/tsc"): # Default location on MacOS
149+
cmd = [get_node_path(), "/usr/local/bin/tsc", "-v"]
150+
else:
151+
cmd = ["tsc", "-v"]
146152
return _execute_cmd_and_parse_version_from_output(cmd)
147153

148154
def _execute_cmd_and_parse_version_from_output(cmd):
155+
if os.name != 'nt': # Linux/MacOS
156+
cmd = "'" + "' '".join(cmd) + "'"
149157
output = subprocess.check_output(cmd, shell=True).decode('UTF-8')
150158

151159
# Use regex to parse the verion number from <output> e.g. parse

0 commit comments

Comments
 (0)