feat: working through the dynamic testing portion of ligmata
This commit is contained in:
parent
8859e43ac9
commit
90fdc7aa06
9 changed files with 113 additions and 58 deletions
75
scripts/v1
75
scripts/v1
|
|
@ -1,75 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const src_path = path.join(__dirname, "..", "src");
|
||||
let day = 1;
|
||||
|
||||
try {
|
||||
day = +fs.readdirSync(src_path).
|
||||
filter(i => i.includes("day")).
|
||||
sort((a, b) => {
|
||||
return +b.substring(3) - a.substring(3);
|
||||
})[0].substring(3) + 1;
|
||||
|
||||
if (isNaN(day)) {
|
||||
console.log("day is nan");
|
||||
day = 1;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("error", e.message);
|
||||
console.log("day is 1");
|
||||
day = 1;
|
||||
}
|
||||
|
||||
const day_name = `day${day}`;
|
||||
const day_path = path.join(src_path, day_name);
|
||||
try { fs.unlinkSync(day_path); } catch (e) { }
|
||||
try { fs.mkdirSync(day_path); } catch (e) { }
|
||||
|
||||
function create_class(item) {
|
||||
fs.writeFileSync(path.join(day_path, item.name), `export default class ${item.class} {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
}`);
|
||||
}
|
||||
|
||||
function create_function(item) {
|
||||
fs.writeFileSync(path.join(day_path, item.name), `export default function ${item.fn}(${item.args}): ${item.return} {
|
||||
|
||||
}`);
|
||||
}
|
||||
|
||||
[{
|
||||
name: "single-linked-list.ts",
|
||||
class: "LinkedList",
|
||||
}, {
|
||||
name: "doubly-linked-list.ts",
|
||||
class: "LinkedList",
|
||||
}, {
|
||||
name: "array-list.ts",
|
||||
class: "ArrayList",
|
||||
}, {
|
||||
name: "queue.ts",
|
||||
class: "Queue",
|
||||
}, {
|
||||
name: "stack.ts",
|
||||
class: "Stack",
|
||||
}].forEach(c => create_class(c));
|
||||
|
||||
[{
|
||||
name: "insertion-sort.ts",
|
||||
fn: "insertion_sort",
|
||||
args: "arr: number[]",
|
||||
"return": "void",
|
||||
}, {
|
||||
name: "merge-sort.ts",
|
||||
fn: "merge_sort",
|
||||
args: "arr: number[]",
|
||||
"return": "void",
|
||||
}].forEach(f => create_function(f));
|
||||
|
||||
const align = require("./align-configs");
|
||||
align.jest(day_name);
|
||||
align.ts_config(day_name);
|
||||
Loading…
Add table
Add a link
Reference in a new issue