mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
fix: use + instead of # in package paths inside node_modules/.pnpm (#3314)
This commit is contained in:
5
.changeset/shiny-olives-wash.md
Normal file
5
.changeset/shiny-olives-wash.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"dependency-path": major
|
||||
---
|
||||
|
||||
Use + instead of # to escape / in paths.
|
||||
@@ -131,7 +131,7 @@ export function parse (dependencyPath: string) {
|
||||
}
|
||||
|
||||
export function depPathToFilename (depPath: string, lockfileDir: string) {
|
||||
const filename = depPathToFilenameUnescaped(depPath, lockfileDir).replace(/\//g, '#')
|
||||
const filename = depPathToFilenameUnescaped(depPath, lockfileDir).replace(/\//g, '+')
|
||||
if (filename.length > 120) {
|
||||
return `${filename.substring(0, 50)}_${crypto.createHash('md5').update(filename).digest('hex')}`
|
||||
}
|
||||
@@ -148,5 +148,5 @@ function depPathToFilenameUnescaped (depPath: string, lockfileDir: string) {
|
||||
}
|
||||
|
||||
const absolutePath = normalize(path.join(lockfileDir, depPath.slice(5)))
|
||||
return `local#${absolutePath.replace(':', '#')}`
|
||||
return `local+${absolutePath.replace(':', '+')}`
|
||||
}
|
||||
|
||||
@@ -120,12 +120,12 @@ test('resolve()', () => {
|
||||
|
||||
test('depPathToFilename()', () => {
|
||||
expect(depPathToFilename('/foo/1.0.0', process.cwd())).toBe('foo@1.0.0')
|
||||
expect(depPathToFilename('/@foo/bar/1.0.0', process.cwd())).toBe('@foo#bar@1.0.0')
|
||||
expect(depPathToFilename('github.com/something/foo/0000', process.cwd())).toBe('github.com#something#foo@0000')
|
||||
expect(depPathToFilename('/@foo/bar/1.0.0', process.cwd())).toBe('@foo+bar@1.0.0')
|
||||
expect(depPathToFilename('github.com/something/foo/0000', process.cwd())).toBe('github.com+something+foo@0000')
|
||||
|
||||
const filename = depPathToFilename('file:./test/foo-1.0.0.tgz_foo@2.0.0', process.cwd())
|
||||
expect(filename).toMatch(/^local#.*#foo-1\.0\.0\.tgz_foo@2\.0\.0$/)
|
||||
expect(filename).toMatch(/^local\+.*\+foo-1\.0\.0\.tgz_foo@2\.0\.0$/)
|
||||
expect(filename).not.toContain(':')
|
||||
|
||||
expect(depPathToFilename('abcd/'.repeat(200), process.cwd())).toBe('abcd#abcd#abcd#abcd#abcd#abcd#abcd#abcd#abcd#abcd#_36cae148b21d1f0b46577e42f8f4dbae')
|
||||
expect(depPathToFilename('abcd/'.repeat(200), process.cwd())).toBe('abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+_27524303f1ddd808db67f175ff83606e')
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ Object {
|
||||
"entries": Object {
|
||||
".pnpm": Object {
|
||||
"entries": Object {
|
||||
"@zkochan#git-config@0.1.0": Object {
|
||||
"@zkochan+git-config@0.1.0": Object {
|
||||
"entries": Object {
|
||||
"node_modules": Object {
|
||||
"entries": Object {
|
||||
@@ -63,7 +63,7 @@ Object {
|
||||
"entries": Object {
|
||||
"git-config": Object {
|
||||
"entryType": "symlink",
|
||||
"target": "./.pnpm/@zkochan#git-config@0.1.0/node_modules/@zkochan/git-config",
|
||||
"target": "./.pnpm/@zkochan+git-config@0.1.0/node_modules/@zkochan/git-config",
|
||||
},
|
||||
},
|
||||
"entryType": "directory",
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('FUSE handlers', () => {
|
||||
handlers.readdir('/.pnpm', (returnCode, files) => {
|
||||
expect(returnCode).toBe(0)
|
||||
expect(files!.sort()).toStrictEqual([
|
||||
'@zkochan#git-config@0.1.0',
|
||||
'@zkochan+git-config@0.1.0',
|
||||
'ini@1.3.8',
|
||||
'is-positive@1.0.0',
|
||||
].sort())
|
||||
@@ -39,11 +39,11 @@ describe('FUSE handlers', () => {
|
||||
expect(returnCode).toBe(0)
|
||||
expect(files).toStrictEqual(['is-positive'])
|
||||
})
|
||||
handlers.readdir('/.pnpm/@zkochan#git-config@0.1.0/node_modules/@zkochan', (returnCode, files) => {
|
||||
handlers.readdir('/.pnpm/@zkochan+git-config@0.1.0/node_modules/@zkochan', (returnCode, files) => {
|
||||
expect(returnCode).toBe(0)
|
||||
expect(files).toStrictEqual(['git-config'])
|
||||
})
|
||||
handlers.readdir('/.pnpm/@zkochan#git-config@0.1.0/node_modules/@zkochan/git-config', (returnCode, files) => {
|
||||
handlers.readdir('/.pnpm/@zkochan+git-config@0.1.0/node_modules/@zkochan/git-config', (returnCode, files) => {
|
||||
expect(returnCode).toBe(0)
|
||||
expect(files!.sort()).toStrictEqual([
|
||||
'package.json',
|
||||
@@ -57,14 +57,14 @@ describe('FUSE handlers', () => {
|
||||
'index.js',
|
||||
].sort())
|
||||
})
|
||||
handlers.readdir('/.pnpm/@zkochan#git-config@0.1.0/node_modules/@zkochan/git-config/test', (returnCode, files) => {
|
||||
handlers.readdir('/.pnpm/@zkochan+git-config@0.1.0/node_modules/@zkochan/git-config/test', (returnCode, files) => {
|
||||
expect(returnCode).toBe(0)
|
||||
expect(files!.sort()).toStrictEqual([
|
||||
'index.js',
|
||||
'fixtures',
|
||||
].sort())
|
||||
})
|
||||
handlers.readdir('/.pnpm/@zkochan#git-config@0.1.0/node_modules/@zkochan/git-config/does-not-exist', (returnCode, files) => {
|
||||
handlers.readdir('/.pnpm/@zkochan+git-config@0.1.0/node_modules/@zkochan/git-config/does-not-exist', (returnCode, files) => {
|
||||
expect(returnCode).toBe(Fuse.ENOENT)
|
||||
})
|
||||
handlers.readdir('/.pnpm/is-positive@1.0.0/node_modules/is-positive', (returnCode, files) => {
|
||||
@@ -76,20 +76,20 @@ describe('FUSE handlers', () => {
|
||||
'readme.md',
|
||||
].sort())
|
||||
})
|
||||
handlers.readdir('/.pnpm/@zkochan#git-config@0.1.0/node_modules/@types', (returnCode) => {
|
||||
handlers.readdir('/.pnpm/@zkochan+git-config@0.1.0/node_modules/@types', (returnCode) => {
|
||||
expect(returnCode).toBe(Fuse.ENOENT)
|
||||
})
|
||||
})
|
||||
it('getattr', () => {
|
||||
handlers.getattr('/.pnpm/@zkochan#git-config@0.1.0/node_modules/@zkochan/git-config/index.js', (returnCode, stat) => {
|
||||
handlers.getattr('/.pnpm/@zkochan+git-config@0.1.0/node_modules/@zkochan/git-config/index.js', (returnCode, stat) => {
|
||||
expect(returnCode).toBe(0)
|
||||
expect(stat.mode).toBe(33188)
|
||||
})
|
||||
handlers.getattr('/.pnpm/@zkochan#git-config@0.1.0/node_modules/@zkochan/git-config/test/fixtures', (returnCode, stat) => {
|
||||
handlers.getattr('/.pnpm/@zkochan+git-config@0.1.0/node_modules/@zkochan/git-config/test/fixtures', (returnCode, stat) => {
|
||||
expect(returnCode).toBe(0)
|
||||
expect(stat.mode).toBe(16877)
|
||||
})
|
||||
handlers.getattr('/.pnpm/@zkochan#git-config@0.1.0/node_modules/@zkochan/git-config/index.jsx', (returnCode, stat) => {
|
||||
handlers.getattr('/.pnpm/@zkochan+git-config@0.1.0/node_modules/@zkochan/git-config/index.jsx', (returnCode, stat) => {
|
||||
expect(returnCode).toBe(Fuse.ENOENT)
|
||||
})
|
||||
handlers.getattr('/.pnpm/is-positive@1.0.0/node_modules/is-positive/package.json', (returnCode, stat) => {
|
||||
@@ -98,7 +98,7 @@ describe('FUSE handlers', () => {
|
||||
})
|
||||
})
|
||||
it('open and read', (done) => {
|
||||
const p = '/.pnpm/@zkochan#git-config@0.1.0/node_modules/@zkochan/git-config/index.js'
|
||||
const p = '/.pnpm/@zkochan+git-config@0.1.0/node_modules/@zkochan/git-config/index.js'
|
||||
handlers.open(p, 0, (exitCode, fd) => {
|
||||
expect(exitCode).toBe(0)
|
||||
expect(fd && fd > 0).toBeTruthy()
|
||||
|
||||
@@ -408,7 +408,7 @@ test('scoped peer dependency is linked', async () => {
|
||||
prepareEmpty()
|
||||
await addDependenciesToPackage({}, ['for-testing-scoped-peers'], await testDefaults())
|
||||
|
||||
const pkgVariation = path.resolve('node_modules/.pnpm/@having#scoped-peer@1.0.0_@scoped+peer@1.0.0/node_modules')
|
||||
const pkgVariation = path.resolve('node_modules/.pnpm/@having+scoped-peer@1.0.0_@scoped+peer@1.0.0/node_modules')
|
||||
await okFile(path.join(pkgVariation, '@having', 'scoped-peer'))
|
||||
await okFile(path.join(pkgVariation, '@scoped', 'peer'))
|
||||
})
|
||||
@@ -896,7 +896,7 @@ test('local tarball dependency with peer dependency', async () => {
|
||||
], await testDefaults({ reporter }))
|
||||
|
||||
const integrityLocalPkgDirs = (await fs.readdir('node_modules/.pnpm'))
|
||||
.filter((dir) => dir.startsWith('local#'))
|
||||
.filter((dir) => dir.startsWith('local+'))
|
||||
|
||||
expect(integrityLocalPkgDirs.length).toBe(1)
|
||||
|
||||
@@ -913,7 +913,7 @@ test('local tarball dependency with peer dependency', async () => {
|
||||
|
||||
{
|
||||
const updatedLocalPkgDirs = (await fs.readdir('node_modules/.pnpm'))
|
||||
.filter((dir) => dir.startsWith('local#'))
|
||||
.filter((dir) => dir.startsWith('local+'))
|
||||
expect(updatedLocalPkgDirs).toStrictEqual(integrityLocalPkgDirs)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user