diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/commands/pack.test.js b/packages/acceptance-tests/pkg-tests-specs/sources/commands/pack.test.js index 8cefaf95e19..21138f0727e 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/commands/pack.test.js +++ b/packages/acceptance-tests/pkg-tests-specs/sources/commands/pack.test.js @@ -765,7 +765,7 @@ describe(`Commands`, () => { await run(`install`); await run(`pack`, `--out`, `%s.tgz`); - expect(xfs.existsSync(`${path}/@scope-test.tgz`)).toEqual(true); + expect(xfs.existsSync(`${path}/@scope_test.tgz`)).toEqual(true); }), ); @@ -791,7 +791,7 @@ describe(`Commands`, () => { await run(`install`); await run(`pack`, `--out`, `%s-%v.tgz`); - expect(xfs.existsSync(`${path}/@scope-test-0.0.1.tgz`)).toEqual(true); + expect(xfs.existsSync(`${path}/@scope_test-0.0.1.tgz`)).toEqual(true); }), ); diff --git a/packages/yarnpkg-core/sources/structUtils.ts b/packages/yarnpkg-core/sources/structUtils.ts index b47708ebed8..62316eea9bf 100644 --- a/packages/yarnpkg-core/sources/structUtils.ts +++ b/packages/yarnpkg-core/sources/structUtils.ts @@ -665,7 +665,7 @@ export function stringifyLocator(locator: Locator) { */ export function slugifyIdent(ident: Ident) { if (ident.scope !== null) { - return `@${ident.scope}-${ident.name}`; + return `@${ident.scope}_${ident.name}`; } else { return ident.name; } diff --git a/packages/yarnpkg-core/tests/structUtils.test.ts b/packages/yarnpkg-core/tests/structUtils.test.ts new file mode 100644 index 00000000000..f0e33f2247c --- /dev/null +++ b/packages/yarnpkg-core/tests/structUtils.test.ts @@ -0,0 +1,13 @@ +import * as structUtils from '../sources/structUtils'; + +describe(`structUtils`, () => { + describe(`slugifyIdent`, () => { + it(`should return a unique slug string with scope`, () => { + const slugA = structUtils.slugifyIdent({scope: `myscope`, name: `user-email`}); + expect(slugA).toEqual(`@myscope_user-email`); + const slugB = structUtils.slugifyIdent({scope: `myscope-user`, name: `email`}); + expect(slugB).toEqual(`@myscope-user_email`); + expect(slugA).not.toEqual(slugB); + }); + }); +});