mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
fix(schema): do not override user serverDir
(#28249)
This commit is contained in:
parent
b327651de3
commit
ed54884c20
@ -158,7 +158,7 @@ export default defineUntypedSchema({
|
||||
$resolve: async (val: string | undefined, get): Promise<string> => {
|
||||
const isV4 = ((await get('future') as Record<string, unknown>).compatibilityVersion === 4)
|
||||
|
||||
return resolve(await get('rootDir') as string, (val || isV4) ? 'server' : resolve(await get('srcDir') as string, 'server'))
|
||||
return resolve(isV4 ? await get('rootDir') as string : await get('srcDir') as string, val ?? 'server')
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -77,6 +77,23 @@ describe('nuxt folder structure', () => {
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
it('should not override value from user for serverDir', async () => {
|
||||
const result = await applyDefaults(NuxtConfigSchema, { future: { compatibilityVersion: 4 }, serverDir: '/myServer' })
|
||||
expect(getDirs(result as unknown as NuxtOptions)).toMatchInlineSnapshot(`
|
||||
{
|
||||
"dir": {
|
||||
"app": "<cwd>/app",
|
||||
"modules": "<cwd>/modules",
|
||||
"public": "<cwd>/public",
|
||||
},
|
||||
"rootDir": "<cwd>",
|
||||
"serverDir": "/myServer",
|
||||
"srcDir": "<cwd>/app",
|
||||
"workspaceDir": "<cwd>",
|
||||
}
|
||||
`)
|
||||
})
|
||||
})
|
||||
|
||||
function getDirs (options: NuxtOptions) {
|
||||
|
Loading…
Reference in New Issue
Block a user