File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -451,7 +451,9 @@ def reverse_find_json_path(window, json_file_path):
451451 paths = [window .active_view ().file_name ()] + window .folders ()
452452 root_dir = next ((reverse_find_root_folder (p ) for p in paths if p ), None )
453453
454- root_dir or print_status_msg (COULDNT_FIND_MIX_EXS )
454+ if not root_dir :
455+ sublime .message_dialog (COULDNT_FIND_MIX_EXS )
456+ print_status_msg (COULDNT_FIND_MIX_EXS )
455457
456458 return root_dir and path .join (root_dir , json_file_path ) or None
457459
@@ -467,13 +469,14 @@ def merge_mix_settings_and_params(window, params):
467469 return
468470
469471 root_dir = path .dirname (mix_settings_path )
470- build_dir = path .join (root_dir , '_build' )
471472
472473 if 'abs_file_path' in params :
473474 params .setdefault ('file_path' , path .relpath (params ['abs_file_path' ], root_dir ))
474475 del params ['abs_file_path' ]
475476
476- save_json_file (path .join (build_dir , FILE_NAMES .REPEAT_JSON ), params )
477+ build_dir = Path (root_dir ) / '_build'
478+ build_dir .exists () or build_dir .mkdir ()
479+ save_json_file (str (build_dir / FILE_NAMES .REPEAT_JSON ), params )
477480
478481 mix_params = load_json_file (mix_settings_path )
479482 mix_params = remove_help_info (mix_params )
Original file line number Diff line number Diff line change 1414MIX_RESULT_FILE_REGEX = r'(\S+?[/\\]\S+?\.[a-zA-Z]+):(\d+)(?::(\d+))?'
1515
1616COULDNT_FIND_MIX_EXS = \
17- 'Error: could not find a mix.exs file and the _build/ directory !\n ' + \
18- 'Make sure that you are in a mix project and that `mix \' do \' deps.get, compile` has been run .'
17+ 'Error: could not find a mix.exs file!\n ' + \
18+ 'Make sure that you are in a mix project.'
1919
2020def print_status_msg (msg ):
2121 print (PRINT_PREFIX , msg )
@@ -53,9 +53,17 @@ def reverse_find_root_folder(bottom_path):
5353 parent_path = bottom_path .parent if bottom_path .is_file () else bottom_path
5454
5555 while True :
56- if all ((parent_path / p ).exists () for p in ['mix.exs' , '_build' ]):
56+ # We have to check for the root mix.exs, ignoring possible sub-app mix files.
57+ if (parent_path / 'mix.exs' ).exists () \
58+ and (
59+ (parent_path / 'mix.lock' ).exists ()
60+ or (parent_path / '_build' ).exists ()
61+ or parent_path .name != 'apps' and not (parent_path .parent / 'mix.exs' ).exists ()
62+ ):
5763 return str (parent_path )
64+
5865 old_path , parent_path = parent_path , parent_path .parent
66+
5967 if old_path == parent_path :
6068 break
6169
You can’t perform that action at this time.
0 commit comments