Skip to content

Commit

Permalink
test: Add a test for themes from dependencies using Layout.vue as ent…
Browse files Browse the repository at this point in the history
…ry point
  • Loading branch information
ocavue committed Apr 28, 2019
1 parent 41b5cfb commit 1145447
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions packages/@vuepress/core/lib/node/loadTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,7 @@ module.exports = function loadTheme (ctx) {
function normalizeThemePath (resolved) {
const { entry, name, fromDep } = resolved
if (fromDep) {
const packageRoot = require.resolve(`${name}/package.json`)
const { main } = require(packageRoot)
if (main.endsWith('.vue')) {
// For those cases that "main" field is set to an non-index file
// e.g. `layouts/Layout.vue`
return packageRoot
} else {
// For those cases that "index.js" is not at package root
// e.g. `lib/index.js` (#1362)
return parse(require.resolve(name)).dir
}
return parse(require.resolve(name)).dir
} else if (entry.endsWith('.js') || entry.endsWith('.vue')) {
return parse(entry).dir
} else {
Expand Down Expand Up @@ -97,6 +87,8 @@ function resolveTheme (ctx, resolver, ignoreLocal, theme) {
// 2. From dep
} else if (isString(theme)) {
const resolved = resolver.resolve(theme, sourceDir)
console.log('resolveTheme, theme=', theme, 'sourceDir=', sourceDir, 'resolver=', resolver)
console.log('resolved:', resolved)
if (resolved.entry === null) {
throw new Error(`Cannot resolve theme: ${theme}.`)
}
Expand Down

0 comments on commit 1145447

Please sign in to comment.