-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtranspileTypeScript.js
More file actions
72 lines (58 loc) · 1.8 KB
/
transpileTypeScript.js
File metadata and controls
72 lines (58 loc) · 1.8 KB
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
// Begin ---------------------------------------------------------------
/**
* Transpiles TypeScript code.
*
* @function transpileTypeScript
*
* @param {string} in_moduleName - Module name which contains the action
* @param {string} in_actionName - Action name which contains the TypeScript code
* @param {boolean} in_showOutput - Flag whether output should be displayed
* @returns {string} result - Result of TypeScript code transpilation
*
* @author Stefan Schnell <mail@stefan-schnell.de>
* @license MIT
* @version 0.7.0
*
* @example
* var in_moduleName = "de.stschnell";
* var in_actionName = "testTypeScript";
* var in_showOutput = false;
*
* Checked with Aria Automation 8.13.1, 8.16.0 and 8.18.0
*/
var _transpileTypeScriptNS = {
main : function(moduleName, actionName, showOutput) {
if (typeof showOutput !== "boolean") {
showOutput = false;
}
try {
var typescriptSource = System.getModule("de.stschnell")
.getActionAsText(moduleName, actionName);
if (showOutput) {
System.log(typescriptSource);
}
var transpileResult = System.getModule("de.stschnell.typescript")
.transpileTypeScriptToJavaScript(typescriptSource, actionName);
if (showOutput) {
System.log(transpileResult.javascriptSource);
}
System.log(transpileResult.diagnosticMessages);
return transpileResult.javascriptSource;
} catch (exception) {
System.log(exception);
}
}
};
if (
String(in_moduleName).trim() !== "" &&
String(in_actionName).trim() !== ""
) {
return _transpileTypeScriptNS.main(
in_moduleName,
in_actionName,
in_showOutput
);
} else {
throw new Error("in_moduleName or in_actionName argument can not be null");
}
// End -----------------------------------------------------------------