@@ -84,7 +84,6 @@ def plugin_loaded():
8484 else :
8585 print ("ref view not found" )
8686 log .debug ("plugin_loaded ended" )
87- _check_typescript_version ()
8887
8988
9089def plugin_unloaded ():
@@ -98,67 +97,3 @@ def plugin_unloaded():
9897 if ref_info :
9998 ref_view .settings ().set ('refinfo' , ref_info .as_value ())
10099 cli .service .exit ()
101-
102-
103- _UPDATE_TS_MESSAGE = "Warning from TypeScript Sublime Text plugin:\n \n \
104- Detected command-line TypeScript compiler version '{0}'. The TypeScript \
105- Sublime Text plugin is using compiler version '{1}'. There may be \
106- differences in behavior between releases.\n \n \
107- To update your command-line TypeScript compiler to the latest release, run \
108- 'npm update -g typescript'."
109-
110- def _check_typescript_version ():
111- """
112- Notify user to upgrade npm typescript. Do this only once every time the
113- plugin is updated.
114- """
115- settings = sublime .load_settings ('Preferences.sublime-settings' )
116- cached_plugin_version = settings .get ("typescript_plugin_tsc_version" )
117-
118- try :
119- plugin_tsc_version = _get_plugin_tsc_version ()
120-
121- if cached_plugin_version != plugin_tsc_version :
122- # The version number getting from the tsc command is different to
123- # the version number stored in the setting file. This means user
124- # has just updated the plugin.
125-
126- npm_tsc_version = _get_npm_tsc_version ()
127-
128- if npm_tsc_version != plugin_tsc_version :
129- sublime .message_dialog (_UPDATE_TS_MESSAGE .format (
130- npm_tsc_version , plugin_tsc_version ))
131-
132- # Update the version in setting file so we don't show this
133- # message twice.
134- settings .set ("typescript_plugin_tsc_version" , plugin_tsc_version )
135- sublime .save_settings ("Preferences.sublime-settings" )
136-
137- except Exception as error :
138- log .error (error )
139-
140- def _get_plugin_tsc_version ():
141- cmd = [get_node_path (), TSC_PATH , "-v" ]
142- return _execute_cmd_and_parse_version_from_output (cmd )
143-
144- def _is_executable (path ):
145- return os .path .isfile (path ) and os .access (path , os .X_OK )
146-
147- def _get_npm_tsc_version ():
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" ]
152- return _execute_cmd_and_parse_version_from_output (cmd )
153-
154- def _execute_cmd_and_parse_version_from_output (cmd ):
155- if os .name != 'nt' : # Linux/MacOS
156- cmd = "'" + "' '" .join (cmd ) + "'"
157- output = subprocess .check_output (cmd , shell = True ).decode ('UTF-8' )
158-
159- # Use regex to parse the verion number from <output> e.g. parse
160- # "1.5.0-beta" from "message TS6029: Version 1.5.0-beta\r\n".
161- match_object = re .search ("Version\s*([\w.-]+)" , output , re .IGNORECASE )
162- if match_object is None :
163- raise Exception ("Cannot parse version number from ouput: '{0}'" .format (output ))
164- return match_object .groups ()[0 ]
0 commit comments