Skip to content

Commit

Permalink
fix: installation of packages with () in scope name
Browse files Browse the repository at this point in the history
close #6348
  • Loading branch information
zkochan committed Apr 3, 2023
1 parent af3e555 commit bb0bd38
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Expand Up @@ -162,7 +162,6 @@ export function revertFromInlineSpecifiersFormat (lockfile: InlineSpecifiersLock
export function convertNewDepPathToOldDepPath (oldDepPath: string) {
if (!oldDepPath.includes('@', 2)) return oldDepPath
const index = oldDepPath.indexOf('@', oldDepPath.indexOf('/@') + 2)
if (oldDepPath.includes('(') && index > oldDepPath.indexOf('(')) return oldDepPath
return `${oldDepPath.substring(0, index)}/${oldDepPath.substring(index + 1)}`
}

Expand Down
8 changes: 8 additions & 0 deletions packages/dependency-path/test/index.ts
Expand Up @@ -98,6 +98,14 @@ test('parse()', () => {
version: '1.0.0',
})

expect(parse('/@(-.-)/foo/1.0.0(@types/babel__core@7.1.14)(foo@1.0.0)')).toStrictEqual({
host: undefined,
isAbsolute: false,
name: '@(-.-)/foo',
peersSuffix: '(@types/babel__core@7.1.14)(foo@1.0.0)',
version: '1.0.0',
})

expect(() => parse('/foo/bar')).toThrow(/\/foo\/bar is an invalid relative dependency path/)

expect(parse('file:project(foo@1.0.0)')).toStrictEqual({
Expand Down
7 changes: 7 additions & 0 deletions pkg-manager/core/test/lockfile.ts
Expand Up @@ -1596,3 +1596,10 @@ test('lockfile is not written when it has no changes', async () => {
await install(manifest, await testDefaults())
expect(await fs.stat(WANTED_LOCKFILE)).toHaveProperty('mtimeMs', initialMtime)
})

test('installation should work with packages that have () in the scope name', async () => {
prepareEmpty()
const opts = await testDefaults()
const manifest = await addDependenciesToPackage({}, ['@(-.-)/env@0.3.1'], opts)
await install(manifest, opts)
})

0 comments on commit bb0bd38

Please sign in to comment.