diff --git a/README.md b/README.md index c14fb3b..6c1bc57 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ node lexme.js ## Start ```bash -node main.js -inp= -o= -t= <-nb|--no-beautify> <-logs> +node main.js -inp= -o= -t= <-nb|--no-beautify> -logs -web-template= # or ./run.sh ``` @@ -35,6 +35,7 @@ Result fill write in file. -t= -nb|--no-beautify -logs +-web-template= ``` ## Test diff --git a/main.js b/main.js index 671cd72..b90438b 100644 --- a/main.js +++ b/main.js @@ -50,8 +50,16 @@ var post_process_lexer = function (_string) { if(args["t"] !== undefined) { switch (args["t"]) { case "web": + if(args["web-template"]){ + if(!fs.existsSync(args["web-template"])){ + throw "Not exist file: " + args["web-template"]; + } - _string = "(function () {var deps = [];define(deps, function(){\n" + _string + "return Lexer; \n});})();"; + var template = fs.readFileSync(args["web-template"], "utf8"); + _string = template.replace(/<%%LEXER%%>/gm, _string); + } else { + _string = "(function () {var deps = [];define(deps, function(){\n" + _string + "return Lexer; \n});})();"; + } break; case "node": _string += "\n module.exports = Lexer"; @@ -59,7 +67,6 @@ var post_process_lexer = function (_string) { } } - _string = process_metatags(_string); if( !(args["no-beautify"] || args["nb"]) ) {