-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
77 lines (54 loc) · 2.29 KB
/
main.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
define(function (require, exports, module) {
"use strict";
var CommandManager = brackets.getModule("command/CommandManager"),
Menus = brackets.getModule("command/Menus");
var DocumentManager = brackets.getModule("document/DocumentManager");
var ExtensionUtils = brackets.getModule("utils/ExtensionUtils");
var NodeDomain = brackets.getModule("utils/NodeDomain"),
ShellDomain = new NodeDomain("elmDomain",
ExtensionUtils.getModulePath(module,
"node/command"));
ExtensionUtils.loadStyleSheet(module, "styles/style.css");
var InfoPanel = require("modules/Info-Panel").InfoPanel;
var panel = new InfoPanel();
panel.init();
panel.show();
var buffer = "";
$(ShellDomain).on("stdout", function(evt, data) {
buffer += data;
panel.updateStatus("Success");
});
$(ShellDomain).on("stderr", function(evt, data) {
buffer += data;
panel.updateStatus("Error");
});
$(ShellDomain).on("finished", function(evt, data) {
panel.appendOutput(buffer);
buffer = "";
});
$(ShellDomain).on("clear", function() {
});
function handleBuild() {
var curOpenDir = DocumentManager.getCurrentDocument().file._parentPath;
var curOpenFile = DocumentManager.getCurrentDocument().file._path;
CommandManager.execute("file.saveAll");
ShellDomain.exec("execute",
"elm-make --yes " + curOpenFile,
curOpenDir,
brackets.platform === "win",
"cmd.exe");
}
var build = "elm.buid"; // package-style naming to avoid collisions
CommandManager.register("elm-make current file", build, handleBuild);
var menu = Menus.addMenu("Elm","foobarcode.elm");
menu.addMenuItem(build);
require("elm-mode");
var LanguageManager = brackets.getModule("language/LanguageManager");
LanguageManager.defineLanguage("elm", {
name: "Elm",
mode: "elm",
fileExtensions: ["elm"],
blockComment: ["{-", "-}"],
lineComment: ["--"]
});
});