Skip to content

Commit

Permalink
fix: issues with storybook and the new lockfile format
Browse files Browse the repository at this point in the history
close #5976
  • Loading branch information
zkochan committed Jan 30, 2023
1 parent 5716822 commit c8df0f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/strong-poets-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pnpm/dependency-path": patch
"pnpm": patch
---

Directories inside the virtual store should not contain the ( or ) chars. This is to fix issues with storybook and the new v6 `pnpm-lock.yaml` lockfile format [#5976](https://github.com/pnpm/pnpm/issues/5976).
6 changes: 5 additions & 1 deletion packages/dependency-path/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ export function parse (dependencyPath: string) {
}

export function depPathToFilename (depPath: string) {
const filename = depPathToFilenameUnescaped(depPath).replace(/[\\/:*?"<>|]/g, '+')
const filename = depPathToFilenameUnescaped(depPath)
.replace(/[\\/:*?"<>|]/g, '+')
.replace(/\)\(/g, '_')
.replace(/\(/, '_')
.replace(/\)$/, '')
if (filename.length > 120 || filename !== filename.toLowerCase() && !filename.startsWith('file+')) {
return `${filename.substring(0, 50)}_${createBase32Hash(filename)}`
}
Expand Down
1 change: 1 addition & 0 deletions packages/dependency-path/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ test('depPathToFilename()', () => {
expect(depPathToFilename('/@foo/bar/1.0.0')).toBe('@foo+bar@1.0.0')
expect(depPathToFilename('github.com/something/foo/0000?v=1')).toBe('github.com+something+foo@0000+v=1')
expect(depPathToFilename('\\//:*?"<>|')).toBe('++@+++++++')
expect(depPathToFilename('/foo/1.0.0(react@16.0.0)(react-dom@16.0.0)')).toBe('foo@1.0.0_react@16.0.0_react-dom@16.0.0')

const filename = depPathToFilename('file:test/foo-1.0.0.tgz_foo@2.0.0')
expect(filename).toBe('file+test+foo-1.0.0.tgz_foo@2.0.0')
Expand Down

0 comments on commit c8df0f5

Please sign in to comment.