@@ -273,7 +273,25 @@ const make = Effect.gen(function* () {
273273 Duration . infinity ,
274274 ) ;
275275 const scratchProbe = probe . pipe ( Effect . onInterrupt ( ( ) => invalidate ) ) ;
276- const scratchRoot = scratchProbe . pipe ( Effect . map ( Result . getSuccess ) ) ;
276+ // A symlinked scratch folder lets the No project live at either the link or its target.
277+ const scratchProjectRoot = ( root : string ) =>
278+ fileSystem . realPath ( root ) . pipe (
279+ Effect . flatMap ( ( target ) =>
280+ target === root
281+ ? Effect . succeed ( root )
282+ : projects
283+ . getByWorkspaceRoot ( target )
284+ . pipe ( Effect . map ( ( project ) => ( Option . isSome ( project ) ? target : root ) ) ) ,
285+ ) ,
286+ Effect . orElseSucceed ( ( ) => root ) ,
287+ ) ;
288+ const scratchRoot = scratchProbe . pipe (
289+ Effect . flatMap ( ( probed ) =>
290+ Result . isSuccess ( probed )
291+ ? scratchProjectRoot ( probed . success ) . pipe ( Effect . asSome )
292+ : Effect . succeedNone ,
293+ ) ,
294+ ) ;
277295
278296 const makeScratchFolder = ( folder : string ) =>
279297 fileSystem
@@ -282,8 +300,9 @@ const make = Effect.gen(function* () {
282300
283301 const ensureScratchProject : ManagedProjectFolders [ "Service" ] [ "ensureScratchProject" ] = Effect . gen (
284302 function * ( ) {
285- const workspaceRoot = yield * scratchProbe . pipe ( Effect . flatMap ( Effect . fromResult ) ) ;
286- yield * makeScratchFolder ( workspaceRoot ) ;
303+ const probedRoot = yield * scratchProbe . pipe ( Effect . flatMap ( Effect . fromResult ) ) ;
304+ yield * makeScratchFolder ( probedRoot ) ;
305+ const workspaceRoot = yield * scratchProjectRoot ( probedRoot ) ;
287306 const id = yield * random
288307 . uuidV4 ( )
289308 . pipe ( Effect . mapError ( ( cause ) => new ScratchProjectError ( { workspaceRoot, cause } ) ) ) ;
0 commit comments