Skip to content

Commit

Permalink
prebuild脚本修改
Browse files Browse the repository at this point in the history
  • Loading branch information
tedjmzhang committed Jun 3, 2024
1 parent ccb5b19 commit 59c7aed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"scripts": {
"docs:dev": "vitepress dev",
"docs:build": "node ./src/hooks.js && vitepress build",
"docs:build": "node ./src/hooks.js prebuild && vitepress build",
"docs:preview": "vitepress preview"
},
"dependencies": {
Expand Down
14 changes: 4 additions & 10 deletions src/hooks.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ let { program } = require("commander");
let { readFileSync, readdirSync, writeFileSync } = require("fs");
let path = require('path');

program.command('prebuild').description('发布之前执行的hook')
program.command('prebuild')
.description('发布之前执行的hook')
.action(() => {
appendJSToMD(__dirname)
})

program.parse();

function appendJSToMD(dirPath) {
console.log(__dirname)
let currentDirName = path.basename(dirPath)
let dirInfoList = readdirSync(dirPath, { withFileTypes: true });
// 该文件夹下面有index.js 或者dirname.js 同时该文件下面有index.md
Expand Down Expand Up @@ -41,11 +42,4 @@ function appendJSToMD(dirPath) {
dirs.forEach(item => {
appendJSToMD(path.resolve(dirPath, item.name))
})



console.log('dir', dirInfoList);
}


appendJSToMD(__dirname);
}

0 comments on commit 59c7aed

Please sign in to comment.