Skip to content

Commit 970b434

Browse files
authored
fix: Only empty the .temp directory at most once per run (fix #2254) (#2612)
1 parent 45b4ba6 commit 970b434

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
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+
//
7+
// Known issue: This can cause the `.temp` directory to grow while the server
8+
// is running, but the impact is limited because the `.temp` directory will
9+
// be cleared when restarting the server.
10+
// See discussion in https://github.com/vuejs/vuepress/pull/2612
11+
let alreadyEmptied = false
12+
313
/**
414
* Create a dynamic temp utility context that allow to lanuch
515
* multiple apps with isolated context at the same time.
@@ -19,8 +29,9 @@ module.exports = function createTemp (tempPath) {
1929

2030
if (!fs.existsSync(tempPath)) {
2131
fs.ensureDirSync(tempPath)
22-
} else {
32+
} else if (!alreadyEmptied) {
2333
fs.emptyDirSync(tempPath)
34+
alreadyEmptied = true
2435
}
2536

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

0 commit comments

Comments
 (0)