Skip to content

Commit fae9476

Browse files
committed
non-blocking
1 parent c1cca16 commit fae9476

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

myst_libre/tools/myst_client.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,22 @@ def check_node_installed(self):
4040
EnvironmentError: If Node.js is not installed or not found in PATH.
4141
"""
4242
try:
43-
result = subprocess.run(['node', '--version'],env=os.environ, capture_output=True, text=True, check=True)
44-
self.cprint(f"✓ Node.js is installed: {result.stdout.strip()}","green")
43+
process = subprocess.Popen(['node', '--version'],
44+
env=os.environ,
45+
stdout=subprocess.PIPE,
46+
stderr=subprocess.PIPE,
47+
text=True)
48+
stdout, stderr = process.communicate()
49+
if process.returncode != 0:
50+
raise subprocess.CalledProcessError(process.returncode, process.args, stdout, stderr)
51+
52+
self.cprint(f"✓ Node.js is installed: {stdout.strip()}", "green")
4553
except subprocess.CalledProcessError as e:
46-
raise EnvironmentError("Node.js is not installed or not found in PATH. Please install Node.js to proceed.") from e
54+
self.cprint(f"✗ Error checking Node.js version: {e.stderr.strip()}", "red")
55+
raise
56+
except Exception as e:
57+
self.cprint(f"✗ Unexpected error occurred: {str(e)}", "red")
58+
raise
4759

4860
def check_mystmd_installed(self):
4961
"""
@@ -53,10 +65,21 @@ def check_mystmd_installed(self):
5365
EnvironmentError: If MyST markdown tool is not installed or not found in PATH.
5466
"""
5567
try:
56-
result = subprocess.run([self.executable, '--version'],env=os.environ, capture_output=True, text=True, check=True)
57-
self.cprint(f"✓ mystmd is installed: {result.stdout.strip()}","green")
68+
process = subprocess.Popen([self.executable, '--version'],
69+
env=os.environ,
70+
stdout=subprocess.PIPE,
71+
stderr=subprocess.PIPE,
72+
text=True)
73+
stdout, stderr = process.communicate()
74+
if process.returncode != 0:
75+
raise subprocess.CalledProcessError(process.returncode, process.args, stdout, stderr)
76+
self.cprint(f"✓ mystmd is installed: {stdout.strip()}","green")
5877
except subprocess.CalledProcessError as e:
59-
raise EnvironmentError(f"{self.executable} is not installed or not found in PATH. Please install mystmd to proceed.") from e
78+
self.cprint(f"✗ Error checking myst version: {e.stderr.strip()}", "red")
79+
raise
80+
except Exception as e:
81+
self.cprint(f"✗ Unexpected error occurred: {str(e)}", "red")
82+
raise
6083

6184
def run_command(self, *args, env_vars={}):
6285
"""

0 commit comments

Comments
 (0)