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 }));