From c07c711cb788d6487bb9ab6cafaa77b71d27ee0d Mon Sep 17 00:00:00 2001 From: ludanxer Date: Wed, 27 Nov 2019 14:35:14 +0800 Subject: [PATCH 1/3] fix invalid temp config in config.js --- packages/@vuepress/core/lib/node/App.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@vuepress/core/lib/node/App.js b/packages/@vuepress/core/lib/node/App.js index 46d6b0914b..540c2fd604 100755 --- a/packages/@vuepress/core/lib/node/App.js +++ b/packages/@vuepress/core/lib/node/App.js @@ -46,10 +46,6 @@ module.exports = class App { logger.warn(`Source directory doesn't exist: ${chalk.yellow(this.sourceDir)}`) } - const { tempPath, writeTemp } = createTemp(options.temp) - this.tempPath = tempPath - this.writeTemp = writeTemp - this.vuepressDir = path.resolve(this.sourceDir, '.vuepress') this.libDir = path.join(__dirname, '../') } @@ -72,6 +68,10 @@ module.exports = class App { this.siteConfig = siteConfig } + const { tempPath, writeTemp } = createTemp(this.options.temp ? this.options.temp : this.siteConfig.temp) + this.tempPath = tempPath + this.writeTemp = writeTemp + // TODO custom cwd. this.cwd = process.cwd() From c59db3ca31b226f34d9b845961f9e0c718e10c49 Mon Sep 17 00:00:00 2001 From: ludanxer Date: Wed, 27 Nov 2019 14:55:59 +0800 Subject: [PATCH 2/3] use short-circuit evaluation to replace ternary operator --- packages/@vuepress/core/lib/node/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vuepress/core/lib/node/App.js b/packages/@vuepress/core/lib/node/App.js index 540c2fd604..02cf4d7ad6 100755 --- a/packages/@vuepress/core/lib/node/App.js +++ b/packages/@vuepress/core/lib/node/App.js @@ -68,7 +68,7 @@ module.exports = class App { this.siteConfig = siteConfig } - const { tempPath, writeTemp } = createTemp(this.options.temp ? this.options.temp : this.siteConfig.temp) + const { tempPath, writeTemp } = createTemp(this.options.temp || this.siteConfig.temp) this.tempPath = tempPath this.writeTemp = writeTemp From 36015ea97825c920f9d809cd19b6c867350264de Mon Sep 17 00:00:00 2001 From: meteorlxy Date: Wed, 27 Nov 2019 15:20:53 +0800 Subject: [PATCH 3/3] tweaks --- packages/@vuepress/core/lib/node/App.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/@vuepress/core/lib/node/App.js b/packages/@vuepress/core/lib/node/App.js index 02cf4d7ad6..2a6cdc261b 100755 --- a/packages/@vuepress/core/lib/node/App.js +++ b/packages/@vuepress/core/lib/node/App.js @@ -68,20 +68,24 @@ module.exports = class App { this.siteConfig = siteConfig } - const { tempPath, writeTemp } = createTemp(this.options.temp || this.siteConfig.temp) - this.tempPath = tempPath - this.writeTemp = writeTemp - // TODO custom cwd. this.cwd = process.cwd() this.base = this.siteConfig.base || '/' this.themeConfig = this.siteConfig.themeConfig || {} + // resolve tempPath + const rawTemp = this.options.temp || this.siteConfig.temp + const { tempPath, writeTemp } = createTemp(rawTemp) + this.tempPath = tempPath + this.writeTemp = writeTemp + + // resolve outDir const rawOutDir = this.options.dest || this.siteConfig.dest this.outDir = rawOutDir ? require('path').resolve(this.cwd, rawOutDir) : require('path').resolve(this.sourceDir, '.vuepress/dist') + this.pages = [] // Array this.pluginAPI = new PluginAPI(this) this.ClientComputedMixinConstructor = ClientComputedMixin(this.getSiteData())