diff --git a/src/cmd.js b/src/cmd.js index dc14477..324518d 100644 --- a/src/cmd.js +++ b/src/cmd.js @@ -4,8 +4,6 @@ let output = ""; let pagefile, tempfile; let fs = require("fs"); - - let addCommand = ({prefix,args = myargs}, callback) => { myargs.forEach((elem) =>{ @@ -28,14 +26,15 @@ addCommand({prefix:"-Jsconfig="},(arg) =>{ }) addCommand({prefix:"-page="},(arg) =>{ - pagefile = JSON.parse(fs.readFileSync(arg,"utf-8").toString()) + + pagefile = arg }) addCommand({prefix:"-temp="},(arg) =>{ - tempfile = fs.readFileSync(arg, "utf-8").toString() + tempfile = arg }) -output = jsste.render(pagefile || undefined, tempfile || undefined) +output = jsste.renderFile(pagefile || undefined, tempfile || undefined) addCommand({prefix:"-out"},(arg) =>{ console.log(output) diff --git a/src/index.js b/src/index.js index b882f48..86c648a 100644 --- a/src/index.js +++ b/src/index.js @@ -11,14 +11,16 @@ app.CONST = engine.CONST; * @param {*} filePath * @returns */ -app.renderFile = (filePath) => { +app.renderFile = (filePath, templatePath) => { app.setState({ status: 0, statusMSG: "read file" }); let file = fs.readFileSync(filePath, "utf8"); app.setState({ status: 0, statusMSG: "parse file" }); file = JSON.parse(file); + app.setState({ status: 0, statusMSG: "read template" }); + let temp = fs.readFileSync(templatePath, "utf8"); app.setState({ status: 0, statusMSG: "set Selfpath" }); file["_SELFPATH_"] = path.dirname(filePath); - return engine.render(file); + return engine.render(file,temp); }; /**