Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Toggle individual features (all enabled by default):
| `replaceRoot` | `true` | `/foo/node_modules/.pnpm` → `<ROOT>/node_modules/.pnpm` |
| `replaceWorkspaceWithFileProtocol` | `true` | `file:///foo/packages/core/src` → `<WORKSPACE>/src` |
| `replaceRootWithFileProtocol` | `true` | `file:///foo/node_modules/.pnpm` → `<ROOT>/node_modules/.pnpm` |
| `replacePnpmInner` | `true` | Collapse pnpm's long `.pnpm/...` and global virtual store `pnpm/store/.../links/...` paths to `<PNPM_INNER>` |
| `replacePnpmInner` | `true` | Collapse pnpm's long `.pnpm/...` and global virtual store `<store-dir>/v*/links/...` paths to `<PNPM_INNER>` |
| `replaceTmpDir` | `true` | `os.tmpdir()` paths → `<TEMP>` |
| `replaceHomeDir` | `true` | `os.homedir()` paths → `<HOME>` |
| `transformWin32Path` | `true` | Convert `D:\\foo\\bar` to `/d/foo/bar` |
Expand Down
24 changes: 24 additions & 0 deletions e2e/pnpmGlobalVirtualStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
`"<PNPM_INNER>/babel-loader/lib/index.js"`,
);
});

test('should serialize pnpm global virtual store path (win32)', () => {
const serializer = createSnapshotSerializer({
root: 'D:\\user\\project',
Expand All @@ -47,3 +56,18 @@ test('should serialize pnpm global virtual store path (win32)', () => {
`"\\"<PNPM_INNER>/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(
`"\\"<PNPM_INNER>/@tailwindcss/webpack/dist/index.js\\""`,
);
});
5 changes: 2 additions & 3 deletions src/pnpm/replacePnpmInnerPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ const PNPM_INNER_DELIMITERS = /[\s!"']/;
// local virtual store: .pnpm/<pkg>@<ver>/node_modules
const LOCAL_PNPM_POSIX = /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/g;
const LOCAL_PNPM_WIN32 = /(?<=\\)(\.pnpm\\.+?\\node_modules)(?=\\)/g;
// global virtual store: pnpm/store/<versions>/links/<pkg>/<ver>/<hash>/node_modules
const GLOBAL_PNPM_POSIX =
/(?<=\/)pnpm\/store\/.+?\/links\/.+?\/node_modules(?=\/)/g;
// global virtual store: <store-dir>/v<version>/links/<pkg>/<ver>/<hash>/node_modules
const GLOBAL_PNPM_POSIX = /(?<=\/)v\d+\/links\/.+?\/node_modules(?=\/)/g;
Comment thread
chenjiahan marked this conversation as resolved.

/**
* Replace pnpm virtual store paths with `<PNPM_INNER>` and strip
Expand Down
Loading