2424PLATFORM = platform_switcher .get (sublime .platform ())
2525PLATFORM_ARCHITECTURE = "64bit" if platform .architecture ()[0 ] == "64bit" else "32bit"
2626
27- #PROJECT_TYPE_SUPPORTED = ['empty', 'angularv1', 'angularv2', 'cordova', 'express', 'ionicv1', 'ionicv2', 'node.js', ' react', 'yeoman']
27+ #PROJECT_TYPE_SUPPORTED = ['empty', 'angularv1', 'angularv2', 'cordova', 'express', 'ionicv1', 'ionicv2', 'react', 'yeoman']
2828PROJECT_TYPE_SUPPORTED = ['empty' , 'angularv1' , 'angularv2' , 'cordova' , 'ionicv1' , 'ionicv2' , 'react' , 'yeoman' ]
2929
3030class Hook (object ):
@@ -1196,13 +1196,18 @@ def close(self) :
11961196 self .socket = None
11971197
11981198
1199- def subl (args ):
1200-
1199+ def sublime_executable_path ():
12011200 executable_path = sublime .executable_path ()
12021201 if sublime .platform () == 'osx' :
12031202 app_path = executable_path [:executable_path .rfind (".app/" ) + 5 ]
12041203 executable_path = app_path + "Contents/SharedSupport/bin/subl"
12051204
1205+ return executable_path
1206+
1207+ def subl (args ):
1208+
1209+ executable_path = sublime_executable_path ()
1210+
12061211 if sublime .platform () == 'windows' :
12071212 args = [executable_path ] + args
12081213 else :
@@ -1601,12 +1606,10 @@ def _run(self):
16011606
16021607 args = {"cmd" : cmd , "title" : "JavaScript Enhancements Terminal" , "cwd" : self .working_directory , "syntax" : None , "keep_open" : False }
16031608 view .run_command ('terminal_view_activate' , args = args )
1604-
1605- # stop the current process with SIGINT
1606- self .window .run_command ("terminal_view_send_string" , args = {"string" : "\x03 " })
16071609
1608- # call command
1609- self .window .run_command ("terminal_view_send_string" , args = {"string" : self .path_cli + " " + (" " .join (self .command ))+ "\n " })
1610+ # stop the current process with SIGINT and call the command
1611+ sublime .set_timeout_async (lambda : self .window .run_command ("terminal_view_send_string" , args = {"string" : "\x03 " }) or
1612+ self .window .run_command ("terminal_view_send_string" , args = {"string" : self .path_cli + " " + (" " .join (self .command ))+ "\n " }), 500 )
16101613
16111614 def substitute_placeholders (self , variable ):
16121615
@@ -1795,16 +1798,17 @@ def cordova_prepare_project(project_path, cordova_custom_path):
17951798 view = window .new_file ()
17961799
17971800 if sublime .platform () in ("linux" , "osx" ):
1801+ open_project = (" && " + shlex .quote (sublime_executable_path ()) + " " + shlex .quote (get_project_settings (project_path )["project_file_name" ])) if not is_project_open (get_project_settings (project_path )["project_file_name" ]) else ""
17981802 args = {"cmd" : "/bin/bash -l" , "title" : "Terminal" , "cwd" : project_path , "syntax" : None , "keep_open" : False }
17991803 view .run_command ('terminal_view_activate' , args = args )
1800- window .run_command ("terminal_view_send_string" , args = {"string" : cordova_custom_path + " create temp com.example.hello HelloWorld && mv ./temp /{.[!.],}* ./ && rm -rf temp \n " })
1804+ window .run_command ("terminal_view_send_string" , args = {"string" : cordova_custom_path + " create myApp com.example.hello HelloWorld && mv ./myApp /{.[!.],}* ./; rm -rf myApp" + open_project + " \n " })
18011805 else :
18021806 # windows
18031807 pass
18041808
18051809 add_cordova_settings (project_path , cordova_custom_path )
18061810
1807- open_project_folder (get_project_settings ()["project_file_name" ])
1811+ # open_project_folder(get_project_settings(project_path )["project_file_name"])
18081812
18091813Hook .add ("cordova_after_create_new_project" , cordova_ask_custom_path )
18101814Hook .add ("cordova_add_javascript_project_configuration" , cordova_ask_custom_path )
@@ -1892,17 +1896,16 @@ def ionicv1_prepare_project(project_path, ionicv1_custom_path):
18921896 view = window .new_file ()
18931897
18941898 if sublime .platform () in ("linux" , "osx" ):
1899+ open_project = (" && " + shlex .quote (sublime_executable_path ()) + " " + shlex .quote (get_project_settings (project_path )["project_file_name" ])) if not is_project_open (get_project_settings (project_path )["project_file_name" ]) else ""
18951900 args = {"cmd" : "/bin/bash -l" , "title" : "Terminal" , "cwd" : project_path , "syntax" : None , "keep_open" : False }
18961901 view .run_command ('terminal_view_activate' , args = args )
1897- window .run_command ("terminal_view_send_string" , args = {"string" : ionicv1_custom_path + " start myApp blank --type ionic1 && mv ./myApp/{.[!.],}* ./ && rm -rf myApp\n " })
1902+ window .run_command ("terminal_view_send_string" , args = {"string" : ionicv1_custom_path + " start myApp blank --type ionic1 && mv ./myApp/{.[!.],}* ./; rm -rf myApp" + open_project + " \n " })
18981903 else :
18991904 # windows
19001905 pass
19011906
19021907 add_ionicv1_settings (project_path , ionicv1_custom_path )
19031908
1904- open_project_folder (get_project_settings ()["project_file_name" ])
1905-
19061909Hook .add ("ionicv1_after_create_new_project" , ionicv1_ask_custom_path )
19071910Hook .add ("ionicv1_add_javascript_project_configuration" , ionicv1_ask_custom_path )
19081911
@@ -1990,17 +1993,16 @@ def ionicv2_prepare_project(project_path, ionicv2_custom_path):
19901993 view = window .new_file ()
19911994
19921995 if sublime .platform () in ("linux" , "osx" ):
1996+ open_project = (" && " + shlex .quote (sublime_executable_path ()) + " " + shlex .quote (get_project_settings (project_path )["project_file_name" ])) if not is_project_open (get_project_settings (project_path )["project_file_name" ]) else ""
19931997 args = {"cmd" : "/bin/bash -l" , "title" : "Terminal" , "cwd" : project_path , "syntax" : None , "keep_open" : False }
19941998 view .run_command ('terminal_view_activate' , args = args )
1995- window .run_command ("terminal_view_send_string" , args = {"string" : ionicv2_custom_path + " start myApp && mv ./myApp/{.[!.],}* ./ && rm -rf myApp\n " })
1999+ window .run_command ("terminal_view_send_string" , args = {"string" : ionicv2_custom_path + " start myApp && mv ./myApp/{.[!.],}* ./; rm -rf myApp" + open_project + " \n " })
19962000 else :
19972001 # windows
19982002 pass
19992003
20002004 add_ionicv2_settings (project_path , ionicv2_custom_path )
20012005
2002- open_project_folder (get_project_settings ()["project_file_name" ])
2003-
20042006Hook .add ("ionicv2_after_create_new_project" , ionicv2_ask_custom_path )
20052007Hook .add ("ionicv2_add_javascript_project_configuration" , ionicv2_ask_custom_path )
20062008
@@ -2029,14 +2031,18 @@ def platform_on_done(self, platform):
20292031
20302032 def _run (self ):
20312033 try :
2032- self .command = {
2033- 'run' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_run_options" ][self .command [3 ].replace ('--' , '' )][self .command [2 ]],
2034- 'compile' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_compile_options" ][self .command [3 ].replace ('--' , '' )][self .command [2 ]],
2035- 'build' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_build_options" ][self .command [3 ].replace ('--' , '' )][self .command [2 ]],
2036- 'emulate' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_emulate_options" ][self .command [3 ].replace ('--' , '' )][self .command [2 ]],
2037- 'prepare' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_prepare_options" ][self .command [2 ]],
2038- 'serve' : lambda : self .command + self .settings ["ionicv2_settings" ]["serve_options" ]
2039- }[self .command [1 ]]()
2034+ if self .command [0 ] == "cordova" :
2035+ self .command = {
2036+ 'run' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_run_options" ][self .command [3 ].replace ('--' , '' )][self .command [2 ]],
2037+ 'compile' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_compile_options" ][self .command [3 ].replace ('--' , '' )][self .command [2 ]],
2038+ 'build' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_build_options" ][self .command [3 ].replace ('--' , '' )][self .command [2 ]],
2039+ 'emulate' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_emulate_options" ][self .command [3 ].replace ('--' , '' )][self .command [2 ]],
2040+ 'prepare' : lambda : self .command + self .settings ["ionicv2_settings" ]["platform_prepare_options" ][self .command [2 ]]
2041+ }[self .command [1 ]]()
2042+ else :
2043+ self .command = {
2044+ 'serve' : lambda : self .command + self .settings ["ionicv2_settings" ]["serve_options" ]
2045+ }[self .command [0 ]]()
20402046 except KeyError as err :
20412047 pass
20422048 except Exception as err :
@@ -2084,9 +2090,10 @@ def angularv1_prepare_project(project_path, angularv1_custom_path):
20842090 view = window .new_file ()
20852091
20862092 if sublime .platform () in ("linux" , "osx" ):
2093+ open_project = (" && " + shlex .quote (sublime_executable_path ()) + " " + shlex .quote (get_project_settings (project_path )["project_file_name" ])) if not is_project_open (get_project_settings (project_path )["project_file_name" ]) else ""
20872094 args = {"cmd" : "/bin/bash -l" , "title" : "Terminal" , "cwd" : project_path , "syntax" : None , "keep_open" : False }
20882095 view .run_command ('terminal_view_activate' , args = args )
2089- window .run_command ("terminal_view_send_string" , args = {"string" : angularv1_custom_path + " angular\n " })
2096+ window .run_command ("terminal_view_send_string" , args = {"string" : angularv1_custom_path + " angular" + open_project + " \n " })
20902097 else :
20912098 # windows
20922099 pass
@@ -2173,9 +2180,10 @@ def angularv2_prepare_project(project_path, angularv2_custom_path):
21732180 view = window .new_file ()
21742181
21752182 if sublime .platform () in ("linux" , "osx" ):
2183+ open_project = (" && " + shlex .quote (sublime_executable_path ()) + " " + shlex .quote (get_project_settings (project_path )["project_file_name" ])) if not is_project_open (get_project_settings (project_path )["project_file_name" ]) else ""
21762184 args = {"cmd" : "/bin/bash -l" , "title" : "Terminal" , "cwd" : project_path , "syntax" : None , "keep_open" : False }
21772185 view .run_command ('terminal_view_activate' , args = args )
2178- window .run_command ("terminal_view_send_string" , args = {"string" : angularv2_custom_path + " new myApp && mv ./myApp/{.[!.],}* ./ && rm -rf myApp\n " })
2186+ window .run_command ("terminal_view_send_string" , args = {"string" : angularv2_custom_path + " new myApp && mv ./myApp/{.[!.],}* ./; rm -rf myApp" + open_project + " \n " })
21792187 else :
21802188 # windows
21812189 pass
@@ -2269,17 +2277,16 @@ def react_prepare_project(project_path, react_custom_path):
22692277 view = window .new_file ()
22702278
22712279 if sublime .platform () in ("linux" , "osx" ):
2280+ open_project = (" && " + shlex .quote (sublime_executable_path ()) + " " + shlex .quote (get_project_settings (project_path )["project_file_name" ])) if not is_project_open (get_project_settings (project_path )["project_file_name" ]) else ""
22722281 args = {"cmd" : "/bin/bash -l" , "title" : "Terminal" , "cwd" : project_path , "syntax" : None , "keep_open" : False }
22732282 view .run_command ('terminal_view_activate' , args = args )
2274- window .run_command ("terminal_view_send_string" , args = {"string" : react_custom_path + " myApp && mv ./myApp/{.[!.],}* ./ && rm -rf myApp\n " })
2283+ window .run_command ("terminal_view_send_string" , args = {"string" : react_custom_path + " myApp && mv ./myApp/{.[!.],}* ./; rm -rf myApp" + open_project + " \n " })
22752284 else :
22762285 # windows
22772286 pass
22782287
22792288 add_react_settings (project_path , react_custom_path )
22802289
2281- open_project_folder (get_project_settings ()["project_file_name" ])
2282-
22832290Hook .add ("react_after_create_new_project" , react_ask_custom_path )
22842291Hook .add ("react_add_javascript_project_configuration" , react_ask_custom_path )
22852292
@@ -2313,15 +2320,14 @@ def yeoman_prepare_project(project_path, type):
23132320 view = window .new_file ()
23142321
23152322 if sublime .platform () in ("linux" , "osx" ):
2323+ open_project = (" && " + shlex .quote (sublime_executable_path ()) + " " + shlex .quote (get_project_settings (project_path )["project_file_name" ])) if not is_project_open (get_project_settings (project_path )["project_file_name" ]) else ""
23162324 args = {"cmd" : "/bin/bash -l" , "title" : "Terminal" , "cwd" : project_path , "syntax" : None , "keep_open" : False }
23172325 view .run_command ('terminal_view_activate' , args = args )
2318- window .run_command ("terminal_view_send_string" , args = {"string" : "yo\n " })
2326+ window .run_command ("terminal_view_send_string" , args = {"string" : "yo" + open_project + " \n " })
23192327 else :
23202328 # windows
23212329 pass
23222330
2323- open_project_folder (get_project_settings ()["project_file_name" ])
2324-
23252331Hook .add ("yeoman_after_create_new_project" , yeoman_prepare_project )
23262332
23272333
@@ -2345,7 +2351,7 @@ def project_path_on_done(self, path):
23452351
23462352 path = shlex .quote ( path .strip () )
23472353
2348- if os .path .exists (os .path .join (path , PROJECT_SETTINGS_FOLDER_NAME )):
2354+ if os .path .isdir (os .path .join (path , PROJECT_SETTINGS_FOLDER_NAME )):
23492355 sublime .error_message (path + " is not empty. Can not create the project." )
23502356 return
23512357
@@ -2398,6 +2404,9 @@ def project_path_on_done(self, path):
23982404 Hook .apply (self .project_type + "_after_create_new_project" , path , "create_new_project" )
23992405 Hook .apply ("after_create_new_project" , path , "create_new_project" )
24002406
2407+ if self .project_type == "empty" :
2408+ open_project_folder (get_project_settings (path )["project_file_name" ])
2409+
24012410class add_javascript_project_typeCommand (sublime_plugin .WindowCommand ):
24022411 project_type = None
24032412 settings = None
0 commit comments