Skip to content

Commit 36a9e56

Browse files
authored
Only empty the .temp directory at most once per run (fixes vuejs#2254)
To avoid compilation errors caused by removed files
1 parent 844b56a commit 36a9e56

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/@vuepress/core/lib/node/createTemp.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const { fs, path, chalk, logger } = require('@vuepress/shared-utils')
22

3+
// Only empty the `.temp` directory at most once per run to avoid
4+
// compilation errors caused by removed files.
5+
// See: https://github.com/vuejs/vuepress/issues/2254#issuecomment-689457157
6+
let alreadyEmptied = false
7+
38
/**
49
* Create a dynamic temp utility context that allow to lanuch
510
* multiple apps with isolated context at the same time.
@@ -19,8 +24,9 @@ module.exports = function createTemp (tempPath) {
1924

2025
if (!fs.existsSync(tempPath)) {
2126
fs.ensureDirSync(tempPath)
22-
} else {
27+
} else if (!alreadyEmptied) {
2328
fs.emptyDirSync(tempPath)
29+
alreadyEmptied = true
2430
}
2531

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

0 commit comments

Comments
 (0)