|
1 | 1 | const {
|
2 | 2 | logger,
|
3 | 3 | fs,
|
| 4 | + globby, |
4 | 5 | path: { resolve }
|
5 | 6 | } = require('@vuepress/shared-utils')
|
6 | | -const readdirSync = dir => (fs.existsSync(dir) && fs.readdirSync(dir)) || [] |
7 | 7 |
|
8 | 8 | module.exports = class ThemeAPI {
|
9 | 9 | constructor (theme, parentTheme) {
|
@@ -105,10 +105,12 @@ module.exports = class ThemeAPI {
|
105 | 105 |
|
106 | 106 | function resolveSFCs (dirs) {
|
107 | 107 | return dirs
|
108 | | - .map(layoutDir => |
109 | | - readdirSync(layoutDir) |
110 | | - .filter(filename => filename.endsWith('.vue')) |
111 | | - .map(filename => { |
| 108 | + .map((layoutDir) => |
| 109 | + (fs.existsSync(layoutDir) |
| 110 | + ? globby.sync('**/*.vue', { cwd: layoutDir, absolute: false }) |
| 111 | + : [] |
| 112 | + ) |
| 113 | + .map((filename) => { |
112 | 114 | const componentName = getComponentName(filename)
|
113 | 115 | return {
|
114 | 116 | filename,
|
|
0 commit comments