satisfy typescript for github actions
This commit is contained in:
@@ -6,13 +6,14 @@ const port: number = 8042;
|
|||||||
|
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
let req_path: string;
|
let req_path: string;
|
||||||
if (!req.url.includes(".")) {
|
let req_url = req.url ?? ""; //fucking typescript shit. there will be a url trust me
|
||||||
req_path = path.join(__dirname, "build", req.url, "index.html");
|
if (!req_url.includes(".")) {
|
||||||
|
req_path = path.join(__dirname, "build", req_url, "index.html");
|
||||||
} else {
|
} else {
|
||||||
req_path = path.join(__dirname, "build", req.url);
|
req_path = path.join(__dirname, "build", req_url);
|
||||||
}
|
}
|
||||||
let status_code = 200;
|
let status_code = 200;
|
||||||
//req.url.includes("..")
|
//req_url.includes("..")
|
||||||
if (!req_path.startsWith(path.join(__dirname, "build"))) {
|
if (!req_path.startsWith(path.join(__dirname, "build"))) {
|
||||||
//nice try, bad request
|
//nice try, bad request
|
||||||
res.writeHead(400);
|
res.writeHead(400);
|
||||||
|
|||||||
12
ryuji.ts
12
ryuji.ts
@@ -39,7 +39,8 @@ export class Renderer {
|
|||||||
return `${path1.slice(0, path1.length-1)}${path2}`;
|
return `${path1.slice(0, path1.length-1)}${path2}`;
|
||||||
} else if ((!path1.endsWith("/") && path2.startsWith("/")) || (path1.endsWith("/") && !path2.startsWith("/"))) {
|
} else if ((!path1.endsWith("/") && path2.startsWith("/")) || (path1.endsWith("/") && !path2.startsWith("/"))) {
|
||||||
return `${path1}${path2}`;
|
return `${path1}${path2}`;
|
||||||
} else if (!path1.endsWith("/") && !path2.startsWith("/")) {
|
} else {
|
||||||
|
//} else if (!path1.endsWith("/") && !path2.startsWith("/")) {
|
||||||
return `${path1}/${path2}`;
|
return `${path1}/${path2}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +134,7 @@ export class Renderer {
|
|||||||
if (var_value.length === 0) {
|
if (var_value.length === 0) {
|
||||||
//skip straight to the endfor
|
//skip straight to the endfor
|
||||||
let sliced = matches.slice(index+1, matches.length);
|
let sliced = matches.slice(index+1, matches.length);
|
||||||
let new_index: number;
|
let new_index: number | undefined;
|
||||||
let extra_fors: number = 0;
|
let extra_fors: number = 0;
|
||||||
for (let i=0; i < sliced.length; i++) {
|
for (let i=0; i < sliced.length; i++) {
|
||||||
if (sliced[i][0].startsWith("[[ for:")) {
|
if (sliced[i][0].startsWith("[[ for:")) {
|
||||||
@@ -198,7 +199,7 @@ export class Renderer {
|
|||||||
}
|
}
|
||||||
let var_value2 = Renderer.get_var(var_name2, vars);
|
let var_value2 = Renderer.get_var(var_name2, vars);
|
||||||
if (if_in) {
|
if (if_in) {
|
||||||
var_value2 = var_value2.find((ele) => ele === var_value);
|
var_value2 = var_value2.find((ele: any) => ele === var_value);
|
||||||
}
|
}
|
||||||
if (if_not) {
|
if (if_not) {
|
||||||
//make sure the two compared variables are NOT equal
|
//make sure the two compared variables are NOT equal
|
||||||
@@ -232,6 +233,7 @@ export class Renderer {
|
|||||||
extra_ifs--;
|
extra_ifs--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// @ts-ignore
|
||||||
if (typeof new_index === "undefined") throw Error("`if:` statement missing an `[[ endif ]]`");
|
if (typeof new_index === "undefined") throw Error("`if:` statement missing an `[[ endif ]]`");
|
||||||
index += new_index+1;
|
index += new_index+1;
|
||||||
continue;
|
continue;
|
||||||
@@ -257,8 +259,8 @@ export class Renderer {
|
|||||||
if (current_last[i] !== " ") break;
|
if (current_last[i] !== " ") break;
|
||||||
indentation++;
|
indentation++;
|
||||||
}
|
}
|
||||||
let var_lines: string[] = var_value.split("\n");
|
let var_lines: string[] = var_value.split("\n") as string[]; //dunno why typescript thinks it could be undefined
|
||||||
let var_first: string = var_lines.shift();
|
let var_first: string = var_lines.shift() as string; //we know var_lines has at least one element
|
||||||
//append spaces
|
//append spaces
|
||||||
var_value = var_lines.length === 0 ? var_first : var_first+"\n"+var_lines.map((var_line) => " ".repeat(indentation)+var_line).join("\n");
|
var_value = var_lines.length === 0 ? var_first : var_first+"\n"+var_lines.map((var_line) => " ".repeat(indentation)+var_line).join("\n");
|
||||||
if (exp_parts[0] === "html") {
|
if (exp_parts[0] === "html") {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
"strict": true,
|
||||||
"module": "nodenext",
|
"module": "nodenext",
|
||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "nodenext",
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
|
|||||||
Reference in New Issue
Block a user