diff --git a/cli/src/generate.ts b/cli/src/generate.ts index 48908561..77e2184b 100644 --- a/cli/src/generate.ts +++ b/cli/src/generate.ts @@ -49,18 +49,25 @@ export async function generate(mode: Mode, data: ResolvedData): Promise { } // rewrite git files begin ================================== - if (data.git) - fileList.push(...await readFiles(getTemplate('git'))) - - if (mode === Mode.init) { - const gitignorePath = path.join(cwd, '.gitignore') - const docs = data.docsDir - if (fs.existsSync(gitignorePath)) { - const content = await fs.promises.readFile(gitignorePath, 'utf-8') - fileList.push({ - filepath: '.gitignore', - content: `${content}\n${docs}/.vuepress/.cache\n${docs}/.vuepress/.temp\n${docs}/.vuepress/dist\n`, - }) + if (data.git) { + const gitFiles = await readFiles(getTemplate('git')) + if (mode === Mode.init) { + const gitignorePath = path.join(cwd, '.gitignore') + const docs = data.docsDir + if (fs.existsSync(gitignorePath)) { + const content = await fs.promises.readFile(gitignorePath, 'utf-8') + fileList.push({ + filepath: '.gitignore', + content: `${content}\n${docs}/.vuepress/.cache\n${docs}/.vuepress/.temp\n${docs}/.vuepress/dist\n`, + }) + fileList.push(...gitFiles.filter(({ filepath }) => filepath !== '.gitignore')) + } + else { + fileList.push(...gitFiles) + } + } + else { + fileList.push(...gitFiles) } } // rewrite git files end ==================================== diff --git a/cli/templates/deploy/github/.github/workflows/deploy.yml.handlebars b/cli/templates/deploy/github/.github/workflows/deploy.yml.handlebars index 289ede19..1c77f0c0 100644 --- a/cli/templates/deploy/github/.github/workflows/deploy.yml.handlebars +++ b/cli/templates/deploy/github/.github/workflows/deploy.yml.handlebars @@ -67,4 +67,4 @@ jobs: build_dir: {{docsDir}}/.vuepress/dist env: # @see https://docs.github.com/cn/actions/reference/authentication-in-a-workflow#about-the-github_token-secret - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }} diff --git a/cli/templates/git/.gitignore.handlebars b/cli/templates/git/.gitignore.handlebars index 5b4a3211..2ce874b7 100644 --- a/cli/templates/git/.gitignore.handlebars +++ b/cli/templates/git/.gitignore.handlebars @@ -1,4 +1,4 @@ -node_modules +**/node_modules {{ docsDir }}/.vuepress/.cache {{ docsDir }}/.vuepress/.temp