diff --git a/packages/@vuepress/core/lib/node/createTemp.js b/packages/@vuepress/core/lib/node/createTemp.js index 96b831e349..1f33e5f3a8 100644 --- a/packages/@vuepress/core/lib/node/createTemp.js +++ b/packages/@vuepress/core/lib/node/createTemp.js @@ -1,4 +1,6 @@ const { fs, path, chalk, logger } = require('@vuepress/shared-utils') +const os = require('os') +const process = require('process') /** * Create a dynamic temp utility context that allow to lanuch @@ -12,7 +14,10 @@ const { fs, path, chalk, logger } = require('@vuepress/shared-utils') module.exports = function createTemp (tempPath) { if (!tempPath) { - tempPath = path.resolve(__dirname, '../../.temp') + tempPath = fs.mkdtempSync(path.join(os.tmpdir(), 'vuepress-')) + process.on('exit', _code => { + fs.removeSync(tempPath) + }) } else { tempPath = path.resolve(tempPath) } diff --git a/packages/docs/docs/config/README.md b/packages/docs/docs/config/README.md index 57a120399b..a9253fe5d8 100644 --- a/packages/docs/docs/config/README.md +++ b/packages/docs/docs/config/README.md @@ -69,10 +69,10 @@ Specify the port to use for the dev server. ### temp - Type: `string` -- Default: `/path/to/@vuepress/core/.temp` +- Default: `/tmp/vuepress-SUFFIX` -Specify the temporary directory for client. +Specify the temporary directory for client. `SUFFIX` is a random suffix generated by `fs.mkdtemp`. ### dest @@ -321,7 +321,7 @@ This option is also included in [Plugin API](../plugin/option-api.md#extendmarkd - Default: `['h2', 'h3']` While preparing the page, headers are extracted from the Markdown file and stored in `this.$page.headers`. By default, VuePress will extract `h2` and `h3` elements for you. You can override the headers it pulls out in your `markdown` options. - + ``` js module.exports = { markdown: { diff --git a/packages/docs/docs/zh/config/README.md b/packages/docs/docs/zh/config/README.md index 2696096ef1..0c921edd59 100644 --- a/packages/docs/docs/zh/config/README.md +++ b/packages/docs/docs/zh/config/README.md @@ -67,9 +67,9 @@ module.exports = { ### temp - Type: `string` -- Default: `/path/to/@vuepress/core/.temp` +- Default: `/tmp/vuepress-SUFFIX` -指定客户端文件的临时目录。 +指定客户端文件的临时目录。`SUFFIX` 是 `fs.mkdtemp` 产生的随机后缀。 ### dest @@ -317,7 +317,7 @@ module.exports = { - 默认值: `['h2', 'h3']` Markdown 文件的 headers (标题 & 小标题) 会在准备阶段被提取出来,并存储在 `this.$page.headers` 中。默认情况下,VuePress 会提取 `h2` 和 `h3` 标题。你可以通过这个选项来修改提取出的标题级别。 - + ``` js module.exports = { markdown: {