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 "ENOTDIR: not a directory" error #1564

Merged
merged 2 commits into from
May 11, 2019
Merged
Show file tree
Hide file tree
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
Empty file.
2 changes: 2 additions & 0 deletions __mocks__/vuepress-theme-without-index/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = {}
// This file is just for jest.
4 changes: 4 additions & 0 deletions __mocks__/vuepress-theme-without-index/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "vuepress-theme-without-index",
"main": "Layout.vue"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('App', () => {
theme: '@vuepress/default',
emp: docsTempPath
})
await app.process()
expect(app.sourceDir).toBe(docsPath)
}))
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
title: 'Hello VuePress',
description: '# Hello, VuePress!',
theme: 'vuepress-theme-without-index'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Hello, VuePress!
12 changes: 1 addition & 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