From eb9f337defdc1361d7fd209fd7a93709cbcc64f3 Mon Sep 17 00:00:00 2001 From: Abdullah Tayel Date: Tue, 21 May 2019 02:04:41 +0200 Subject: [PATCH] #538 Automatically check if node_modules/typescript/lib exists --- typescript/libs/editor_client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/typescript/libs/editor_client.py b/typescript/libs/editor_client.py index 42bed262..1926eaa1 100644 --- a/typescript/libs/editor_client.py +++ b/typescript/libs/editor_client.py @@ -55,6 +55,13 @@ def initialize(self): if tsdk_location: proc_file = os.path.join(tsdk_location, "tsserver.js") global_vars._tsc_path = os.path.join(tsdk_location, "tsc.js") + + # else check for local tsserver inside of node_modules + elif len(sublime.active_window().folders()) > 0: + if os.path.exists(os.path.join(sublime.active_window().folders()[0], 'node_modules/typescript/lib')): + local_tsdk_location = os.path.join(sublime.active_window().folders()[0], 'node_modules/typescript/lib') + proc_file = os.path.join(local_tsdk_location, "tsserver.js") + global_vars._tsc_path = os.path.join(local_tsdk_location, "tsc.js") else: # otherwise, get tsserver.js from package directory proc_file = os.path.join(PLUGIN_DIR, "tsserver", "tsserver.js")