diff --git a/README.md b/README.md index f45bdd9..dce1169 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ Toggle individual features (all enabled by default): | `replaceRoot` | `true` | `/foo/node_modules/.pnpm` → `/node_modules/.pnpm` | | `replaceWorkspaceWithFileProtocol` | `true` | `file:///foo/packages/core/src` → `/src` | | `replaceRootWithFileProtocol` | `true` | `file:///foo/node_modules/.pnpm` → `/node_modules/.pnpm` | -| `replacePnpmInner` | `true` | Collapse pnpm's long `.pnpm/...` and global virtual store `pnpm/store/.../links/...` paths to `` | +| `replacePnpmInner` | `true` | Collapse pnpm's long `.pnpm/...` and global virtual store `/v*/links/...` paths to `` | | `replaceTmpDir` | `true` | `os.tmpdir()` paths → `` | | `replaceHomeDir` | `true` | `os.homedir()` paths → `` | | `transformWin32Path` | `true` | Convert `D:\\foo\\bar` to `/d/foo/bar` | diff --git a/e2e/pnpmGlobalVirtualStore.test.ts b/e2e/pnpmGlobalVirtualStore.test.ts index 13f7c0a..83b61d2 100644 --- a/e2e/pnpmGlobalVirtualStore.test.ts +++ b/e2e/pnpmGlobalVirtualStore.test.ts @@ -32,6 +32,15 @@ test('should serialize pnpm global virtual store path with scoped package', () = ); }); +test('should serialize pnpm global virtual store path with custom store dir (posix)', () => { + const filePath = + '/Users/runner/setup-pnpm/node_modules/.bin/store/v11/links/@/babel-loader/10.1.1/2e0a48b2c431adf706e0ceeb7230f336ebd327dd1253fa61217daa3dbb5c78dc/node_modules/babel-loader/lib/index.js'; + + expect(filePath).toMatchInlineSnapshot( + `"/babel-loader/lib/index.js"`, + ); +}); + test('should serialize pnpm global virtual store path (win32)', () => { const serializer = createSnapshotSerializer({ root: 'D:\\user\\project', @@ -47,3 +56,18 @@ test('should serialize pnpm global virtual store path (win32)', () => { `"\\"/react/index.js\\""`, ); }); + +test('should serialize pnpm global virtual store path with custom store dir (win32)', () => { + const serializer = createSnapshotSerializer({ + features: { + transformWin32Path: true, + }, + }); + + const filePath = + 'D:\\.pnpm-store\\v11\\links\\@tailwindcss\\webpack\\4.3.3\\ec899805fefbf1ad652f8b65ed5d2e0d6fffbd615e2734cb7010eb00a7c4b15d\\node_modules\\@tailwindcss\\webpack\\dist\\index.js'; + + expect(serializer.serialize(filePath)).toMatchInlineSnapshot( + `"\\"/@tailwindcss/webpack/dist/index.js\\""`, + ); +}); diff --git a/src/pnpm/replacePnpmInnerPath.ts b/src/pnpm/replacePnpmInnerPath.ts index 11aa667..21875e8 100644 --- a/src/pnpm/replacePnpmInnerPath.ts +++ b/src/pnpm/replacePnpmInnerPath.ts @@ -4,9 +4,8 @@ const PNPM_INNER_DELIMITERS = /[\s!"']/; // local virtual store: .pnpm/@/node_modules const LOCAL_PNPM_POSIX = /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/g; const LOCAL_PNPM_WIN32 = /(?<=\\)(\.pnpm\\.+?\\node_modules)(?=\\)/g; -// global virtual store: pnpm/store//links////node_modules -const GLOBAL_PNPM_POSIX = - /(?<=\/)pnpm\/store\/.+?\/links\/.+?\/node_modules(?=\/)/g; +// global virtual store: /v/links////node_modules +const GLOBAL_PNPM_POSIX = /(?<=\/)v\d+\/links\/.+?\/node_modules(?=\/)/g; /** * Replace pnpm virtual store paths with `` and strip