File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ let ensuredDir: string | null = null;
3030 */
3131export function ensureGordonHome ( ) : string {
3232 const dir = resolveGordonDir ( ) ;
33+ // Re-check whenever the resolved dir changes (tests point GORDON_HOME at a
34+ // temp dir per case) or the directory has since been removed.
3335 if ( dir !== ensuredDir || ! existsSync ( dir ) ) {
3436 try {
3537 mkdirSync ( dir , { recursive : true } ) ;
@@ -56,5 +58,12 @@ export function getGordonDir(): string {
5658 return ensureGordonHome ( ) ;
5759}
5860
59- /** Pre-resolved Gordon directory for the current process */
60- export const GORDON_DIR = getGordonDir ( ) ;
61+ /**
62+ * Pre-resolved Gordon directory for the current process.
63+ *
64+ * Deliberately a PURE path computation: doing filesystem I/O at module-import
65+ * time runs before any test's setup can redirect the home, and the resulting
66+ * first-import path would be cached for the whole process. Directory creation
67+ * happens at write time via ensureGordonHome() / getGordonDir() instead.
68+ */
69+ export const GORDON_DIR = resolveGordonDir ( ) ;
You can’t perform that action at this time.
0 commit comments