fix(schema): app/ dir backwards compatibility (#27529)

This commit is contained in:
Harlan Wilton 2024-06-12 04:47:42 +10:00 committed by GitHub
parent 6bbc85ade9
commit bdf8f9e0dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
import { existsSync } from 'node:fs'
import { readdir } from 'node:fs/promises'
import { defineUntypedSchema } from 'untyped'
import { join, relative, resolve } from 'pathe'
import { isDebug, isDevelopment, isTest } from 'std-env'
@ -117,7 +118,16 @@ export default defineUntypedSchema({
}
const srcDir = resolve(rootDir, 'app')
if (!existsSync(srcDir)) {
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)
}
}
}
if (srcDirFiles.size === 0) {
for (const file of ['app.vue', 'App.vue']) {
if (existsSync(resolve(rootDir, file))) {
return rootDir