diff --git a/docs/format.js b/docs/.format/format.js similarity index 89% rename from docs/format.js rename to docs/.format/format.js index 80a698475..b0cc4226f 100644 --- a/docs/format.js +++ b/docs/.format/format.js @@ -1,8 +1,8 @@ -const file = require('./.format/file'); +const file = require('./file'); const sgf = require('staged-git-files'); const path = require('path'); -const sortByHeading = require('./.format/sortByHeading'); -const chineseFormat = require('./.format/chineseFormat'); +const sortByHeading = require('./sortByHeading'); +const chineseFormat = require('./chineseFormat'); /** * Processors are objects contains two methods: @@ -17,13 +17,13 @@ const loopSideBar = (children, type, lang, prefix) => children .filter((e) => e !== '') .map((x) => ({ - path: path.resolve(__dirname, prefix, `./${x}.md`), + path: path.resolve(__dirname, '..', prefix, `./${x}.md`), type, lang, })); const loopNav = (nav, lang) => nav.map((e) => ({ - path: path.resolve(__dirname, e.link.slice(1), 'README.md'), + path: path.resolve(__dirname, '..', e.link.slice(1), 'README.md'), type: file.NAV_TYPE, lang, })); @@ -39,7 +39,7 @@ const loopType = (sidebar, lang, prefix) => loopSideBar(sidebar[0].children, fil } */ const buildFileList = async () => { - const config = require(`./.vuepress/config`); + const config = require(`../.vuepress/config`); let fileList = []; Object.keys(config.themeConfig.locales).forEach((key) => { const locale = config.themeConfig.locales[key]; @@ -94,6 +94,8 @@ const buildStagedList = async () => { default: fileList = await buildFileList(); } + // console.log(fileList); + // return for (const processor of processors) { // We don't want to mix up processor diff --git a/package.json b/package.json index a770118dc..6cfbd8a59 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "dev": "cross-env NODE_ENV=dev nodemon --inspect lib/index.js", "docs:dev": "vuepress dev docs", "docs:build": "vuepress build docs", - "format": "eslint \"**/*.js\" --fix && node docs/format.js && prettier \"**/*.{js,json,md}\" --write", - "format:staged": "eslint \"**/*.js\" --fix && node docs/format.js --staged && pretty-quick --staged --verbose --pattern \"**/*.{js,json,md}\"", + "format": "eslint \"**/*.js\" --fix && node docs/.format/format.js && prettier \"**/*.{js,json,md}\" --write", + "format:staged": "eslint \"**/*.js\" --fix && node docs/.format/format.js --staged && pretty-quick --staged --verbose --pattern \"**/*.{js,json,md}\"", "format:check": "eslint \"**/*.js\" && prettier-check \"**/*.{js,json,md}\"", "test": "npm run format:check && cross-env NODE_ENV=test jest --coverage --runInBand --forceExit", "jest": "cross-env NODE_ENV=test jest --runInBand --forceExit"