Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Only empty the .temp directory at most once per run (fix #2254) #2612

Merged
merged 2 commits into from
Nov 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/@vuepress/core/lib/node/createTemp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
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

/**
* Create a dynamic temp utility context that allow to lanuch
* multiple apps with isolated context at the same time.
Expand All @@ -19,8 +29,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