File tree Expand file tree Collapse file tree
fixtures/config/root-resolution Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2037,6 +2037,28 @@ describe('loadConfigFromFile', () => {
20372037 } )
20382038} )
20392039
2040+ describe ( 'root resolution' , ( ) => {
2041+ const fixtureRoot = path . resolve (
2042+ import . meta. dirname ,
2043+ './fixtures/config/root-resolution' ,
2044+ )
2045+ const realDir = path . join ( fixtureRoot , 'real' )
2046+ const linkDir = path . join ( fixtureRoot , 'link' )
2047+
2048+ test ( 'resolves a symlinked root to its real path' , async ( ) => {
2049+ const config = await resolveConfig ( { root : linkDir } , 'serve' )
2050+ expect ( config . root ) . toBe ( normalizePath ( fs . realpathSync . native ( realDir ) ) )
2051+ } )
2052+
2053+ test ( 'keeps a symlinked root when resolve.preserveSymlinks is true' , async ( ) => {
2054+ const config = await resolveConfig (
2055+ { root : linkDir , resolve : { preserveSymlinks : true } } ,
2056+ 'serve' ,
2057+ )
2058+ expect ( config . root ) . toBe ( normalizePath ( linkDir ) )
2059+ } )
2060+ } )
2061+
20402062describe ( 'resolveServerOptions' , ( ) => {
20412063 const warnFn = vi . fn ( )
20422064 const logger = { warn : warnFn } as unknown as Logger
Original file line number Diff line number Diff line change 1+ real
Original file line number Diff line number Diff line change 1+
Original file line number Diff line number Diff line change @@ -1600,9 +1600,11 @@ export async function resolveConfig(
16001600 let nonNormalizedResolvedRoot = config . root
16011601 ? path . resolve ( config . root )
16021602 : process . cwd ( )
1603- try {
1604- nonNormalizedResolvedRoot = safeRealpathSync ( nonNormalizedResolvedRoot )
1605- } catch { }
1603+ if ( ! config . resolve ?. preserveSymlinks ) {
1604+ try {
1605+ nonNormalizedResolvedRoot = safeRealpathSync ( nonNormalizedResolvedRoot )
1606+ } catch { }
1607+ }
16061608 const resolvedRoot = normalizePath ( nonNormalizedResolvedRoot )
16071609
16081610 checkBadCharactersInPath (
You can’t perform that action at this time.
0 commit comments