diff options
author | Minteck <contact@minteck.org> | 2021-12-21 15:25:09 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2021-12-21 15:25:09 +0100 |
commit | e703e51c9c09b22e3bcda9a1faf1e05897f60616 (patch) | |
tree | 4fd67a209ad6988fbf569d7dff8bc37ba45baf95 /_mint/index.js | |
download | mint-e703e51c9c09b22e3bcda9a1faf1e05897f60616.tar.gz mint-e703e51c9c09b22e3bcda9a1faf1e05897f60616.tar.bz2 mint-e703e51c9c09b22e3bcda9a1faf1e05897f60616.zip |
Initial commit
Diffstat (limited to '_mint/index.js')
-rw-r--r-- | _mint/index.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/_mint/index.js b/_mint/index.js new file mode 100644 index 0000000..fabe9ff --- /dev/null +++ b/_mint/index.js @@ -0,0 +1,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 +}));
\ No newline at end of file |