Skip to content

Commit

Permalink
Only empty the .temp directory at most once per run (fixes vuejs#2254)
Browse files Browse the repository at this point in the history
To avoid compilation errors caused by removed files
  • Loading branch information
dtinth authored Sep 16, 2020
1 parent 844b56a commit 36a9e56
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/@vuepress/core/lib/node/createTemp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const { fs, path, chalk, logger } = require('@vuepress/shared-utils')

// Only empty the `.temp` directory at most once per run to avoid
// compilation errors caused by removed files.
// See: https://github.com/vuejs/vuepress/issues/2254#issuecomment-689457157
let alreadyEmptied = false

/**
* Create a dynamic temp utility context that allow to lanuch
* multiple apps with isolated context at the same time.
Expand All @@ -19,8 +24,9 @@ module.exports = function createTemp (tempPath) {

if (!fs.existsSync(tempPath)) {
fs.ensureDirSync(tempPath)
} else {
} else if (!alreadyEmptied) {
fs.emptyDirSync(tempPath)
alreadyEmptied = true
}

logger.debug(`Temp directory: ${chalk.gray(tempPath)}`)
Expand Down

0 comments on commit 36a9e56

Please sign in to comment.