@@ -296,18 +296,18 @@ module.exports = class AppContext {
296
296
themeAgreement
297
297
} ) {
298
298
const siteConfigValue = this . siteConfig [ configKey ]
299
- siteAgreement = path . resolve ( this . vuepressDir , siteAgreement )
299
+ siteAgreement = this . resolveSiteAgreementFile ( siteAgreement )
300
300
301
301
const themeConfigValue = this . getThemeConfigValue ( configKey )
302
- themeAgreement = this . getThemeAgreementFile ( themeAgreement )
302
+ themeAgreement = this . resolveThemeAgreementFile ( themeAgreement )
303
303
304
304
return fsExistsFallback ( [
305
305
siteConfigValue ,
306
306
siteAgreement ,
307
307
themeConfigValue ,
308
308
themeAgreement ,
309
309
defaultValue
310
- ] )
310
+ ] . map ( v => v ) )
311
311
}
312
312
313
313
/**
@@ -377,17 +377,39 @@ module.exports = class AppContext {
377
377
return this . themeEntryFile [ key ] || this . parentThemeEntryFile [ key ]
378
378
}
379
379
380
- getThemeAgreementFile ( filepath ) {
380
+ /**
381
+ * Resolve the absolute path of a theme-level agreement file,
382
+ * return `undefined` when it doesn't exists.
383
+ *
384
+ * @param {string } filepath
385
+ * @returns {string|undefined }
386
+ */
387
+
388
+ resolveThemeAgreementFile ( filepath ) {
381
389
const current = path . resolve ( this . themePath , filepath )
382
390
if ( fs . existsSync ( current ) ) {
383
391
return current
384
392
}
385
- const parent = path . resolve ( this . parentThemePath , filepath )
386
- if ( fs . existsSync ( parent ) ) {
387
- return parent
393
+ if ( this . parentThemePath ) {
394
+ const parent = path . resolve ( this . parentThemePath , filepath )
395
+ if ( fs . existsSync ( parent ) ) {
396
+ return parent
397
+ }
388
398
}
389
399
}
390
400
401
+ /**
402
+ * Resolve the absolute path of a site-level agreement file,
403
+ * return `undefined` when it doesn't exists.
404
+ *
405
+ * @param {string } filepath
406
+ * @returns {string|undefined }
407
+ */
408
+
409
+ resolveSiteAgreementFile ( filepath ) {
410
+ return path . resolve ( this . vuepressDir , filepath )
411
+ }
412
+
391
413
/**
392
414
* Get the data to be delivered to the client.
393
415
*
0 commit comments