-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy pathbuild.py
44 lines (38 loc) · 1.71 KB
/
build.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
import sublime_plugin
from ..libs.global_vars import *
from ..libs import cli
class TypescriptBuildCommand(sublime_plugin.WindowCommand):
build_parameters = ""
def run(self):
if get_node_path() is None:
print("Cannot find node. Build cancelled.")
return
file_name = self.window.active_view().file_name()
project_info = cli.service.project_info(file_name)
if project_info["success"]:
body = project_info["body"]
if ("configFileName" in body) and body["configFileName"].endswith(".json"):
tsconfig_dir = dirname(project_info["body"]["configFileName"])
self.window.run_command("exec", {
"cmd": [get_node_path(), get_tsc_path(), "-p", tsconfig_dir],
# regex to capture build result for displaying in the output panel
"file_regex": "^(.+?)\\((\\d+),(\\d+)\\): (.+)$"
})
else:
sublime.active_window().show_input_panel(
"Build parameters: ",
TypescriptBuildCommand.build_parameters, # initial text
lambda params: self.compile_inferred_project(file_name, params),
None, # on change
None # on cancel
)
def compile_inferred_project(self, file_name, params=""):
cmd = [get_node_path(), get_tsc_path(), file_name]
print(cmd)
if params != "":
cmd.extend(params.split(' '))
self.window.run_command("exec", {
"cmd": cmd,
"file_regex": "^(.+?)\\((\\d+),(\\d+)\\): (.+)$"
})
TypescriptBuildCommand.build_parameters = params