mirror of
https://github.com/lucaspalomodevelop/JSSTE.git
synced 2026-03-13 07:19:37 +00:00
add cmd.js
This commit is contained in:
parent
908058bce6
commit
794d6b5550
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
testfiles
|
||||
planning
|
||||
.vscode
|
||||
built
|
||||
|
||||
@ -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",
|
||||
|
||||
36
src/cmd.js
Normal file
36
src/cmd.js
Normal file
@ -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 )
|
||||
})
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user