Skip to content

Commit fc990ea

Browse files
colthreepvmarijnh
authored andcommitted
npm install doesn't break when silent because it doesn't try to write in STDERR/STDOUT
moreover, there are additional error prints to track down installing errors
1 parent f887b44 commit fc990ea

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tern.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import sublime, sublime_plugin
44
import os, sys, platform, subprocess, webbrowser, json, re, time, atexit
5+
from subprocess import CalledProcessError
56
try:
67
# python 2
78
from utils.renderer import create_renderer
@@ -608,13 +609,15 @@ def plugin_loaded():
608609
"Yes, install."):
609610
try:
610611
if hasattr(subprocess, "check_output"):
611-
subprocess.check_output(["npm", "install"], cwd=plugin_dir)
612+
subprocess.check_output(["npm", "--loglevel=silent", "install"], cwd=plugin_dir, shell=windows)
612613
else:
613-
subprocess.check_call(["npm", "install"], cwd=plugin_dir)
614-
except (IOError, OSError) as e:
614+
subprocess.check_call(["npm", "--loglevel=silent", "install"], cwd=plugin_dir, shell=windows)
615+
except (IOError, OSError, CalledProcessError) as e:
615616
msg = "Installation failed. Try doing 'npm install' manually in " + plugin_dir + "."
616-
if hasattr(e, "output"):
617-
msg += " Error message was:\n\n" + e.output
617+
if hasattr(e, "output") and e.output is not None:
618+
msg += "\nError message was:\n\n" + e.output
619+
if hasattr(e, "returncode"):
620+
msg += "\nReturn code was: " + str(e.returncode)
618621
sublime.error_message(msg)
619622
return
620623
tern_command = ["node", os.path.join(plugin_dir, "node_modules/tern/bin/tern"), "--no-port-file"]

0 commit comments

Comments
 (0)