fix: per-user cache folders (#22046)

Fixes https://github.com/microsoft/playwright/issues/21859
This commit is contained in:
Andrey Lushnikov 2023-03-29 17:49:52 +00:00 committed by GitHub
parent 4f4a63096e
commit bb6b4425f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<string, string> = new Map();
const memoryCache = new Map<string, MemoryCache>();