From bb6b4425f703fa1d77fa36100f64080b86550700 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 29 Mar 2023 17:49:52 +0000 Subject: [PATCH] fix: per-user cache folders (#22046) Fixes https://github.com/microsoft/playwright/issues/21859 --- packages/playwright-test/src/common/compilationCache.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/playwright-test/src/common/compilationCache.ts b/packages/playwright-test/src/common/compilationCache.ts index 9f438266fd87b..9d8b4a1977cd6 100644 --- a/packages/playwright-test/src/common/compilationCache.ts +++ b/packages/playwright-test/src/common/compilationCache.ts @@ -19,6 +19,7 @@ import fs from 'fs'; import os from 'os'; import path from 'path'; import { sourceMapSupport } from '../utilsBundle'; +import { sanitizeForFilePath } from '../util'; export type MemoryCache = { codePath: string; @@ -27,7 +28,11 @@ export type MemoryCache = { }; const version = 13; -const cacheDir = process.env.PWTEST_CACHE_DIR || path.join(os.tmpdir(), 'playwright-transform-cache'); + +const DEFAULT_CACHE_DIR_WIN32 = path.join(os.tmpdir(), `playwright-transform-cache`); +const DEFAULT_CACHE_DIR_POSIX = path.join(os.tmpdir(), `playwright-transform-cache-` + sanitizeForFilePath(os.userInfo().username)); + +const cacheDir = process.env.PWTEST_CACHE_DIR || (process.platform === 'win32' ? DEFAULT_CACHE_DIR_WIN32 : DEFAULT_CACHE_DIR_POSIX); const sourceMaps: Map = new Map(); const memoryCache = new Map();