40 lines
No EOL
1.2 KiB
TypeScript
40 lines
No EOL
1.2 KiB
TypeScript
import mtnt from "../plugins/pluginData/mutant_base.json" with { type: "json" }
|
|
|
|
type obj = {
|
|
cat: string,
|
|
code: number[] | string,
|
|
color: string,
|
|
desc: string,
|
|
morph: string,
|
|
root: string,
|
|
short: string,
|
|
src: string
|
|
}
|
|
|
|
function renameSrc(obj: obj) {
|
|
// Build the new filename
|
|
let newFilename
|
|
if (!obj.morph || !obj.color) {
|
|
newFilename = `${obj.short}`;
|
|
}
|
|
else newFilename = `${obj.root}_${obj.morph}_${obj.color}`;
|
|
|
|
// Extract the path and the old filename from the src string
|
|
const path = obj.src.substring(0, obj.src.lastIndexOf("/") + 1);
|
|
const oldFilename = obj.src.substring(obj.src.lastIndexOf("/") + 1);
|
|
|
|
// Replace the old filename with the new one
|
|
obj.src = path + newFilename + oldFilename.substring(oldFilename.lastIndexOf("."));
|
|
|
|
return obj;
|
|
}
|
|
|
|
|
|
const newMtnt = mtnt.map((obj) => renameSrc(obj));
|
|
|
|
if (Deno.cwd().endsWith("lotus")) {
|
|
Deno.writeTextFile("_src/lib/plugins/pluginData/newMutant.json", JSON.stringify(newMtnt, null, 2));
|
|
} else if (Deno.cwd().endsWith("scripts")) {
|
|
Deno.writeTextFile("../plugins/pluginData/newMutant.json", JSON.stringify(newMtnt, null, 2));
|
|
|
|
} |