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
78
79
80
81
|
const fs = require('fs');
const path = require('path');
const beautify = require('js-beautify').js;
global.root = __dirname;
global.constructed = "'use strict';\n\nglobal.MintExceptionManagerError = require('../_mint/internal/_exceptionManager');\n\ntry {\n\n";
class MintcImportError extends Error {
constructor(props) {
super(props);
this.name = "MintcImportError";
}
}
if (fs.existsSync(root + "/temp")) {
fs.rmSync(root + "/temp", { recursive: true });
}
fs.mkdirSync(root + "/temp");
if (fs.existsSync(root + "/../_build")) {
fs.rmSync(root + "/../_build", { recursive: true });
}
fs.mkdirSync(root + "/../_build");
let file = "";
if (typeof process.argv[2] !== "undefined") {
if (fs.existsSync(process.argv[2])) {
file = fs.readFileSync(process.argv[2]).toString();
} else {
throw new MintcImportError("File not found")
}
}
const MintParser = require('./parser/base');
const MintParserComments = require('./parser/comments');
const MintParserModules = require('./parser/modules');
const MintParserVariables = require('./parser/variables');
const MintParserFunctions = require('./parser/functions');
const MintParserThrows = require('./parser/throws');
const MintParserConditions = require('./parser/conditions');
const MintParserStrings = require('./parser/strings');
file = new MintParserComments().parse(file);
console.log(file);
console.log("-------------------");
file = new MintParserModules().parse(file);
console.log(file);
console.log("-------------------");
file = new MintParserVariables().parse(file);
console.log(file);
console.log("-------------------");
file = new MintParserFunctions().parse(file);
console.log(file);
console.log("-------------------");
file = new MintParserThrows().parse(file);
console.log(file);
console.log("-------------------");
file = new MintParserConditions().parse(file);
console.log(file);
console.log("-------------------");
file = new MintParserStrings().parse(file);
console.log(file);
console.log("-------------------");
constructed += file;
constructed += "\n\n} catch (e) { throw new MintExceptionManagerError(e.name, e.message, e.stack); }";
fs.writeFileSync(root + "/../_build/" + (path.basename(process.argv[2], process.argv[2].split(".")[process.argv[2].split(".").length - 1]).substr(0, path.basename(process.argv[2], process.argv[2].split(".")[process.argv[2].split(".").length - 1]).length - 1)) + ".js", beautify(constructed, {
indent_size: 4,
space_in_empty_paren: true,
no_preserve_newlines: true,
max_preserve_newlines: 1,
jslint_happy: true
}));
|