-
Notifications
You must be signed in to change notification settings - Fork 1
/
jpm.py
64 lines (49 loc) · 1.8 KB
/
jpm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import sublime, sublime_plugin
from Default.exec import ExecCommand
import subprocess
import platform
VCVARS_SETTING = "vcvars_bat_path"
def ensure_workdir(variables, kwargs):
if not kwargs.get('working_dir'):
kwargs['working_dir'] = variables.get('project_path') or variables.get('folder')
return kwargs
class JpmBuildCommand(ExecCommand):
def run(self, **kwargs):
kwargs = ensure_workdir(self.window.extract_variables(), kwargs)
settings = self.window.active_view().settings()
cmd = []
if platform.system() == 'Windows':
cmd = ["jpm.bat", "--verbose", "build"]
vcvars = settings.get(VCVARS_SETTING)
if vcvars:
cmd.insert(0, vcvars)
cmd.insert(1, "&")
else:
cmd = ["jpm", "--verbose", "build"]
kwargs['cmd'] = cmd
super().run(**kwargs)
class JpmCleanCommand(ExecCommand):
def run(self, **kwargs):
kwargs = ensure_workdir(self.window.extract_variables(), kwargs)
cmd = []
if platform.system() == 'Windows':
cmd = ["jpm.bat", "--verbose", "clean"]
else:
cmd = ["jpm", "--verbose", "clean"]
kwargs['cmd'] = cmd
super().run(**kwargs)
class JpmTestCommand(ExecCommand):
def run(self, **kwargs):
kwargs = ensure_workdir(self.window.extract_variables(), kwargs)
settings = self.window.active_view().settings()
cmd = []
if platform.system() == 'Windows':
cmd = ["jpm.bat", "--verbose", "test"]
vcvars = settings.get(VCVARS_SETTING)
if vcvars:
cmd.insert(0, vcvars)
cmd.insert(1, "&")
else:
cmd = ["jpm", "--verbose", "test"]
kwargs['cmd'] = cmd
super().run(**kwargs)