Skip to content

Commit

Permalink
🎉 init(monorepo-1): 初始化 move-md-as-home-page 工具函数。
Browse files Browse the repository at this point in the history
  • Loading branch information
ruan-cat committed Nov 30, 2024
1 parent cc3cb93 commit 8e283c4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# vitepress-carbon 首页
1 change: 1 addition & 0 deletions tests/monorepo-1/src/configs/vip/.vitepress/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# vitepress 首页
1 change: 1 addition & 0 deletions tests/monorepo-1/src/configs/vp-hope/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# vuepress-hope 首页
22 changes: 22 additions & 0 deletions tests/monorepo-1/src/tools/move-md-as-home-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { existsSync, copyFileSync } from "node:fs";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

function moveMdAsHomePage(targetSrcDir: string) {
const indexPath = resolve(__dirname, "index.md");
const targetPath = resolve(process.cwd(), targetSrcDir, "index.md");

if (!existsSync(indexPath)) {
console.log(`未发现期望的 ${__dirname}/index.md 首页文件,无法移动文件。`);
return;
}

copyFileSync(indexPath, targetPath);
console.log(`文件已复制到 ${targetPath}`);
}

// 示例调用
moveMdAsHomePage("./docs");
3 changes: 2 additions & 1 deletion tsconfig.md.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},
"include": [
// 匹配本项目内全部的md文件
"**/*.md"
"**/*.md",
"./tests/**/.vitepress/*.md",
],
"exclude": [],
/**
Expand Down

0 comments on commit 8e283c4

Please sign in to comment.