Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
docs: 优化文档显示
Browse files Browse the repository at this point in the history
  • Loading branch information
AIsouler committed Mar 5, 2024
1 parent 552e5a6 commit 31c13ed
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 文件
export const updateAppMd = async (app: RawApp) => {
// 生成应用的 Markdown 文本内容
Expand Down

0 comments on commit 31c13ed

Please sign in to comment.