Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): improve guessing of package names that contain a dot (#5102) #5135

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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