Skip to content

Commit

Permalink
fix(git-tag-name): npm5 has issues with git tags with @ and / chars
Browse files Browse the repository at this point in the history
  • Loading branch information
ramasilveyra committed Jun 27, 2017
1 parent 7408a80 commit f87165d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/tasks/Publish/get-git-tag-name.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { normalisePackageNameNpm } from './normalise-package-name';

export default function getGitTagName(pkg) {
const gitpkgPackageName = `${pkg.name}@${pkg.version}-gitpkg`;
const gitpkgPackageName = `${normalisePackageNameNpm(pkg.name)}-v${pkg.version}-gitpkg`;
return gitpkgPackageName;
}
4 changes: 2 additions & 2 deletions src/tasks/Publish/normalise-package-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export default async function normalisePackageName(name) {
return normalisePackageNameYarn(name);
}

function normalisePackageNameNpm(name) {
export function normalisePackageNameNpm(name) {
return name[0] === '@' ? name.substr(1).replace(/\//g, '-') : name;
}

function normalisePackageNameYarn(name) {
export function normalisePackageNameYarn(name) {
return name[0] === '@' ? name.substr(1).replace('/', '-') : name;
}
2 changes: 1 addition & 1 deletion test/tasks/get-git-tag-name.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import getGitTagName from '../../src/tasks/Publish/get-git-tag-name';

const pkg = { name: 'megapkg', version: '1.0.0' };
const gitTagName = `${pkg.name}@${pkg.version}-gitpkg`;
const gitTagName = `${pkg.name}-v${pkg.version}-gitpkg`;

describe('while using getGitTagName()', () => {
it(`should return "${gitTagName}"`, () => {
Expand Down

0 comments on commit f87165d

Please sign in to comment.