From 36a9e56f958875087803a2b20e79558333581e3e Mon Sep 17 00:00:00 2001 From: Thai Pangsakulyanont Date: Wed, 16 Sep 2020 18:10:15 +0700 Subject: [PATCH 1/2] Only empty the `.temp` directory at most once per run (fixes #2254) To avoid compilation errors caused by removed files --- packages/@vuepress/core/lib/node/createTemp.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/@vuepress/core/lib/node/createTemp.js b/packages/@vuepress/core/lib/node/createTemp.js index 96b831e349..1ef16fc27c 100644 --- a/packages/@vuepress/core/lib/node/createTemp.js +++ b/packages/@vuepress/core/lib/node/createTemp.js @@ -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. @@ -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)}`) From e17602fea7dd2d8d6baef374c2513b94ad033259 Mon Sep 17 00:00:00 2001 From: Thai Pangsakulyanont Date: Sun, 1 Nov 2020 10:32:40 +0700 Subject: [PATCH 2/2] Update createTemp.js --- packages/@vuepress/core/lib/node/createTemp.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/@vuepress/core/lib/node/createTemp.js b/packages/@vuepress/core/lib/node/createTemp.js index 1ef16fc27c..8f20207cb9 100644 --- a/packages/@vuepress/core/lib/node/createTemp.js +++ b/packages/@vuepress/core/lib/node/createTemp.js @@ -3,6 +3,11 @@ 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 +// +// Known issue: This can cause the `.temp` directory to grow while the server +// is running, but the impact is limited because the `.temp` directory will +// be cleared when restarting the server. +// See discussion in https://github.com/vuejs/vuepress/pull/2612 let alreadyEmptied = false /**