mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 00:23:53 +00:00
fix(schema): resolve user-provided serverDir
relative to root (#28700)
This commit is contained in:
parent
49121e768d
commit
cfd9bf61f2
@ -1,7 +1,7 @@
|
|||||||
import { existsSync } from 'node:fs'
|
import { existsSync } from 'node:fs'
|
||||||
import { readdir } from 'node:fs/promises'
|
import { readdir } from 'node:fs/promises'
|
||||||
import { defineUntypedSchema } from 'untyped'
|
import { defineUntypedSchema } from 'untyped'
|
||||||
import { basename, relative, resolve } from 'pathe'
|
import { basename, join, relative, resolve } from 'pathe'
|
||||||
import { isDebug, isDevelopment, isTest } from 'std-env'
|
import { isDebug, isDevelopment, isTest } from 'std-env'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import { findWorkspaceDir } from 'pkg-types'
|
import { findWorkspaceDir } from 'pkg-types'
|
||||||
@ -156,9 +156,12 @@ export default defineUntypedSchema({
|
|||||||
*/
|
*/
|
||||||
serverDir: {
|
serverDir: {
|
||||||
$resolve: async (val: string | undefined, get): Promise<string> => {
|
$resolve: async (val: string | undefined, get): Promise<string> => {
|
||||||
const isV4 = ((await get('future') as Record<string, unknown>).compatibilityVersion === 4)
|
if (val) {
|
||||||
|
const rootDir = await get('rootDir') as string
|
||||||
return resolve(isV4 ? await get('rootDir') as string : await get('srcDir') as string, val ?? 'server')
|
return resolve(rootDir, val)
|
||||||
|
}
|
||||||
|
const isV4 = (await get('future') as Record<string, unknown>).compatibilityVersion === 4
|
||||||
|
return join(isV4 ? await get('rootDir') as string : await get('srcDir') as string, 'server')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user