From 62bf16fdcdf51d9e35fee8fdc053295193198257 Mon Sep 17 00:00:00 2001 From: Aleksey Chichenkov Date: Tue, 29 Jan 2019 12:09:17 +0300 Subject: [PATCH] fix test --- README.md | 4 ++-- main.js | 21 +++++++++++++-------- test.js | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d9345b0..19a6f87 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ node test.js --c=.js ``` ## Also -You can use this syntax for include your code here. +You can use this syntax for include your *.y file. ```bash - <&&REPLACER{}&&> +<&&REPLACER{}&&> ``` ## Special Directives diff --git a/main.js b/main.js index 876ea6d..edeb909 100644 --- a/main.js +++ b/main.js @@ -31,15 +31,20 @@ var temp_fn_out = "temp_" + "file_name" + ".out"; var update_parser_y = function () { var source_parser_y = fs.readFileSync(parser_path + fn_y, "utf8"); - var result = /&&.*?REPLACER\{(.*?)\}&&/gm.exec(source_parser_y); - if(result) { - var file_path = result[1]; - var process_code = fs.readFileSync(file_path, "utf8"); + source_parser_y = source_parser_y.replace(/&&.*?REPLACER\{(.*?)\}&&/gm, function (match, file_path, offset, string) { + return fs.readFileSync(file_path, "utf8"); + }); - source_parser_y = source_parser_y.replace(/&&.*?REPLACER\{(.*?)\}&&/gm, process_code); - - fs.writeFileSync(parser_path + temp_fn_y, source_parser_y); - } + fs.writeFileSync(parser_path + temp_fn_y, source_parser_y); + // var result = /&&.*?REPLACER\{(.*?)\}&&/gm.exec(source_parser_y); + // if(result) { + // var file_path = result[1]; + // var process_code = fs.readFileSync(file_path, "utf8"); + // + // source_parser_y = source_parser_y.replace(/&&.*?REPLACER\{(.*?)\}&&/gm, process_code); + // + // fs.writeFileSync(parser_path + temp_fn_y, source_parser_y); + // } }; var post_process_parser = function () { diff --git a/test.js b/test.js index 856d614..21d8fe0 100644 --- a/test.js +++ b/test.js @@ -4,6 +4,7 @@ var fs = require("fs"); var exec = require('child_process').exec; +var args = require("args-parser")(process.argv); var cfg_path = "config.js"; var config;