Skip to content

Commit c2c8e26

Browse files
azizkprincemaple
authored andcommitted
Commands: added COULDNT_FIND_MIX_EXS message constant
1 parent 7546674 commit c2c8e26

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

commands/mix_format.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ def call_mix_format(window, **kwargs):
7676
cwd = next((reverse_find_root_folder(p) for p in paths if p), None)
7777

7878
if not (cwd or file_path):
79-
print_status_msg(
80-
'Error: could not find a mix.exs file and the _build/ directory! '
81-
+ 'Make sure that you are in a mix project and that `mix do deps.get + compile` was run.'
82-
)
79+
print_status_msg(COULDNT_FIND_MIX_EXS)
8380
return
8481

8582
proc = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

commands/mix_test.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ def run(self, **_kwargs):
3535
sublime_NewFileFlags_NONE = 4
3636
self.window.open_file(mix_settings_path, flags=sublime_NewFileFlags_NONE)
3737
else:
38-
sublime.message_dialog(
39-
'Error: could not find a mix.exs file and the _build/ directory!\n' +
40-
'Make sure that you are in a mix project and that `mix do deps.get + compile` has been run.'
41-
)
38+
sublime.message_dialog(COULDNT_FIND_MIX_EXS)
4239

4340
class MixTestCommand(sublime_plugin.WindowCommand):
4441
def description(self):
@@ -441,10 +438,7 @@ def reverse_find_json_path(window, json_file_path):
441438
paths = [window.active_view().file_name()] + window.folders()
442439
root_dir = next((reverse_find_root_folder(p) for p in paths if p), None)
443440

444-
root_dir or print_status_msg(
445-
'Error: could not find a mix.exs file and the _build/ directory! '
446-
+ 'Make sure that you are in a mix project and that `mix do deps.get + compile` was run.'
447-
)
441+
root_dir or print_status_msg(COULDNT_FIND_MIX_EXS)
448442

449443
return root_dir and path.join(root_dir, json_file_path) or None
450444

commands/utils.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
PRINT_PREFIX = 'ElixirSyntax:'
1212

13+
COULDNT_FIND_MIX_EXS = \
14+
'Error: could not find a mix.exs file and the _build/ directory!\n' + \
15+
'Make sure that you are in a mix project and that `mix \'do\' deps.get, compile` has been run.'
16+
1317
def print_status_msg(msg):
1418
print(PRINT_PREFIX, msg)
1519
sublime.status_message(PRINT_PREFIX + ' ' + msg)
@@ -65,4 +69,4 @@ def load_json_file(file_path):
6569
exists = Path(file_path).exists()
6670
exists and print_status_msg('Error: could not open file: %r\nException: %s' % (file_path, e))
6771

68-
return {}
72+
return {}

0 commit comments

Comments
 (0)