mirror of
https://github.com/AIsouler/GKD_subscription.git
synced 2025-12-20 16:54:43 +08:00
docs: 优化文档显示
This commit is contained in:
34
src/file.ts
34
src/file.ts
@@ -342,6 +342,40 @@ export const checkConfig = (newConfig: RawSubscription) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 导出一个异步函数,用于检查是否存在冗余的应用 Markdown 文件
|
||||||
|
export const checkAndDeleteFiles = async (): Promise<void> => {
|
||||||
|
const currentDir = process.cwd();
|
||||||
|
|
||||||
|
const docsDir = path.join(currentDir, 'docs');
|
||||||
|
const srcAppsDir = path.join(currentDir, 'src/apps');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const files = await fs.readdir(docsDir);
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
if (file.endsWith('.md')) {
|
||||||
|
const tsFileName = file.replace('.md', '.ts');
|
||||||
|
const tsFilePath = path.join(srcAppsDir, tsFileName);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fs.access(tsFilePath, fs.constants.F_OK);
|
||||||
|
} catch (error) {
|
||||||
|
// Check if error object has code property and it's ENOENT
|
||||||
|
if (error && (error as NodeJS.ErrnoException).code === 'ENOENT') {
|
||||||
|
const mdFilePath = path.join(docsDir, file);
|
||||||
|
await fs.unlink(mdFilePath);
|
||||||
|
console.log(`Deleted ${file}`);
|
||||||
|
} else {
|
||||||
|
throw error; // Propagate other errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error occurred:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 导出一个异步函数,用于更新应用的 Markdown 文件
|
// 导出一个异步函数,用于更新应用的 Markdown 文件
|
||||||
export const updateAppMd = async (app: RawApp) => {
|
export const updateAppMd = async (app: RawApp) => {
|
||||||
// 生成应用的 Markdown 文本内容
|
// 生成应用的 Markdown 文本内容
|
||||||
|
|||||||
Reference in New Issue
Block a user