Skip to content

Commit

Permalink
fix(cli): improve guessing of package names that contain a dot (#5102) (
Browse files Browse the repository at this point in the history
  • Loading branch information
iansu authored and arcanis committed Jan 15, 2018
1 parent 05b4e01 commit 1c3a2de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions __tests__/util/guess-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,25 @@ const examples = [
'awesome-name.tar.gz',
];

const dotExamples = [
'awesomename/awesome.name',
'awesomename/awesome.name.git',
'awesomename/awesome.name.tar.gz',
'awesomename/awesome.name.tar.bz2',
];

describe('guessName', () => {
for (const source of examples) {
it(`guess name of ${source}`, () => {
expect(guessName(source)).toBe('awesome-name');
});
}
});

describe('guessName dot examples', () => {
for (const source of dotExamples) {
it(`guess name of ${source}`, () => {
expect(guessName(source)).toBe('awesome.name');
});
}
});
2 changes: 1 addition & 1 deletion src/util/guess-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import url from 'url';

function cleanup(name: string): string {
name = name.replace(/-\d+\.\d+\.\d+/, '');
return name.split('.')[0];
return name.replace(/\.git$|\.zip$|\.tar\.gz$|\.tar\.bz2$/, '');
}

function guessNameFallback(source: string): string {
Expand Down

0 comments on commit 1c3a2de

Please sign in to comment.