diff --git a/.gitignore b/.gitignore index ad3739d..58cfd4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +testfiles planning .vscode built diff --git a/package.json b/package.json index bb4dba0..bdc009b 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ ], "scripts": { "test": "mocha ./test/test.test.js", - "publish": "npm publish --access publish" + "publish": "npm publish --access publish", + "cmd": "node ./src/cmd.js" }, "repository": { "type": "git", diff --git a/src/cmd.js b/src/cmd.js new file mode 100644 index 0000000..e353538 --- /dev/null +++ b/src/cmd.js @@ -0,0 +1,36 @@ +let jsste = require("./index"); +let myargs = process.argv.slice(2); +let path = require("path"); +const { fstat } = require("fs"); +let output = ""; +let pagefile, tempfile; +let fs = require("fs"); + +let addCommand = ({prefix,args = myargs}, callback) => +{ + myargs.forEach((elem) =>{ + if(elem.startsWith(prefix)) + { + elem = elem.replace(prefix,"") + callback(elem); + } + }) +} + + +addCommand({prefix:"-page="},(arg) =>{ + + pagefile = JSON.parse(fs.readFileSync(arg,"utf-8").toString()) + console.log(pagefile) +}) + +addCommand({prefix:"-temp="},(arg) =>{ + tempfile = fs.readFileSync(arg, "utf-8").toString() + console.log(tempfile) +}) + +output = jsste.render(pagefile || undefined, tempfile || undefined) + +addCommand({prefix:"-out"},(arg) =>{ + console.log("output\n", output ) +}) diff --git a/src/engine.js b/src/engine.js index ea12e98..37c5885 100644 --- a/src/engine.js +++ b/src/engine.js @@ -62,6 +62,7 @@ app.render = function (pagecode, templatecode) { if (!templatecode) { try { app.setState({ status: 0, statusMSG: "Load Templatecode" }); + console.log(app.config.templatePath) templatecode = fs.readFileSync( path.join(app.config.templatePath, pagecode["_TEMPLATE_"] + ".tjsste"), "utf-8"