mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(schema): don't use app/
as srcDir
if it doesn't exist (#28176)
This commit is contained in:
parent
eac0734a3b
commit
874829434d
@ -19,7 +19,7 @@ describe('resolveApp', () => {
|
||||
{
|
||||
"components": [],
|
||||
"configs": [],
|
||||
"dir": "<rootDir>/app",
|
||||
"dir": "<rootDir>",
|
||||
"errorComponent": "<repoRoot>/packages/nuxt/src/app/components/nuxt-error-page.vue",
|
||||
"extensions": [
|
||||
".js",
|
||||
|
@ -118,13 +118,15 @@ export default defineUntypedSchema({
|
||||
}
|
||||
|
||||
const srcDir = resolve(rootDir, 'app')
|
||||
if (!existsSync(srcDir)) {
|
||||
return rootDir
|
||||
}
|
||||
|
||||
const srcDirFiles = new Set<string>()
|
||||
if (existsSync(srcDir)) {
|
||||
const files = await readdir(srcDir).catch(() => [])
|
||||
for (const file of files) {
|
||||
if (file !== 'spa-loading-template.html' && !file.startsWith('router.options')) {
|
||||
srcDirFiles.add(file)
|
||||
}
|
||||
const files = await readdir(srcDir).catch(() => [])
|
||||
for (const file of files) {
|
||||
if (file !== 'spa-loading-template.html' && !file.startsWith('router.options')) {
|
||||
srcDirFiles.add(file)
|
||||
}
|
||||
}
|
||||
if (srcDirFiles.size === 0) {
|
||||
|
@ -1,10 +1,14 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { applyDefaults } from 'untyped'
|
||||
|
||||
import { normalize } from 'pathe'
|
||||
import { NuxtConfigSchema } from '../src'
|
||||
import type { NuxtOptions } from '../src'
|
||||
|
||||
vi.mock('node:fs', () => ({
|
||||
existsSync: (id: string) => id.endsWith('app'),
|
||||
}))
|
||||
|
||||
describe('nuxt folder structure', () => {
|
||||
it('should resolve directories for v3 setup correctly', async () => {
|
||||
const result = await applyDefaults(NuxtConfigSchema, {})
|
||||
|
Loading…
Reference in New Issue
Block a user