add -web-template=<web_template_file>

This commit is contained in:
Aleksey Chichenkov 2019-01-31 11:18:26 +03:00
parent 3975898e13
commit ab8477b834
2 changed files with 11 additions and 3 deletions

View File

@ -22,7 +22,7 @@ node lexme.js
## Start
```bash
node main.js -inp=<input_file> -o=<output_path> -t=<web|node> <-nb|--no-beautify> <-logs>
node main.js -inp=<input_file> -o=<output_path> -t=<web|node> <-nb|--no-beautify> -logs -web-template=<web_template_file>
# or
./run.sh
```
@ -35,6 +35,7 @@ Result fill write in <lexer.js> file.
-t=<web|node>
-nb|--no-beautify
-logs
-web-template=<web_template_file>
```
## Test

View File

@ -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"];
}
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"]) ) {