Organize templates into templates/ folder and update detectTemplates logic
This commit is contained in:
+34
-10
@@ -336,21 +336,45 @@ function renameNode(node, subName, isClash = true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function detectTemplates() {
|
function detectTemplates() {
|
||||||
let yamlTpl = 'CatMata.optimized.yaml';
|
const tplDir = 'templates';
|
||||||
|
let yamlTpl = path.join(tplDir, 'CatMata.optimized.yaml');
|
||||||
|
let jsonTpl = path.join(tplDir, 'CatMata.json');
|
||||||
|
|
||||||
if (!fs.existsSync(yamlTpl)) {
|
if (!fs.existsSync(yamlTpl)) {
|
||||||
const yamls = fs.readdirSync('.').filter(f => f.endsWith('.yaml') || f.endsWith('.yml'));
|
if (fs.existsSync(tplDir)) {
|
||||||
const matched = yamls.find(f => f.includes('CatMata'));
|
const yamls = fs.readdirSync(tplDir).filter(f => f.endsWith('.yaml') || f.endsWith('.yml'));
|
||||||
if (matched) yamlTpl = matched;
|
const matched = yamls.find(f => f.includes('CatMata'));
|
||||||
|
if (matched) yamlTpl = path.join(tplDir, matched);
|
||||||
|
} else {
|
||||||
|
yamlTpl = 'CatMata.optimized.yaml';
|
||||||
|
if (!fs.existsSync(yamlTpl)) {
|
||||||
|
const yamls = fs.readdirSync('.').filter(f => f.endsWith('.yaml') || f.endsWith('.yml'));
|
||||||
|
const matched = yamls.find(f => f.includes('CatMata'));
|
||||||
|
if (matched) yamlTpl = matched;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let jsonTpl = 'CatMata.json';
|
|
||||||
if (!fs.existsSync(jsonTpl)) {
|
if (!fs.existsSync(jsonTpl)) {
|
||||||
if (fs.existsSync('CatMata-tun.json')) {
|
if (fs.existsSync(tplDir)) {
|
||||||
jsonTpl = 'CatMata-tun.json';
|
if (fs.existsSync(path.join(tplDir, 'CatMata-tun.json'))) {
|
||||||
|
jsonTpl = path.join(tplDir, 'CatMata-tun.json');
|
||||||
|
} else {
|
||||||
|
const jsons = fs.readdirSync(tplDir).filter(f => f.endsWith('.json'));
|
||||||
|
const matched = jsons.find(f => f.includes('CatMata'));
|
||||||
|
if (matched) jsonTpl = path.join(tplDir, matched);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const jsons = fs.readdirSync('.').filter(f => f.endsWith('.json') && f !== 'subs.json');
|
jsonTpl = 'CatMata.json';
|
||||||
const matched = jsons.find(f => f.includes('CatMata'));
|
if (!fs.existsSync(jsonTpl)) {
|
||||||
if (matched) jsonTpl = matched;
|
if (fs.existsSync('CatMata-tun.json')) {
|
||||||
|
jsonTpl = 'CatMata-tun.json';
|
||||||
|
} else {
|
||||||
|
const jsons = fs.readdirSync('.').filter(f => f.endsWith('.json') && f !== 'subs.json');
|
||||||
|
const matched = jsons.find(f => f.includes('CatMata'));
|
||||||
|
if (matched) jsonTpl = matched;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { yamlTpl, jsonTpl };
|
return { yamlTpl, jsonTpl };
|
||||||
|
|||||||
Reference in New Issue
Block a user