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: use wildcard values as names #165

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/command-parser/expand-npm-wildcard.js
Expand Up @@ -28,7 +28,7 @@ module.exports = class ExpandNpmWildcard {
.filter(script => wildcardRegex.test(script))
.map(script => Object.assign({}, commandInfo, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rolled this line back to what it is on master, as some other information will exist on commandInfo

command: `npm run ${script}${args}`,
name: script
name: (commandInfo.name || '') + script.match(wildcardRegex)[1]
}));
}
};
18 changes: 16 additions & 2 deletions src/command-parser/expand-npm-wildcard.spec.js
Expand Up @@ -40,8 +40,8 @@ it('expands to all scripts matching pattern', () => {
});

expect(parser.parse({ command: 'npm run foo-*-baz qux' })).toEqual([
{ name: 'foo-bar-baz', command: 'npm run foo-bar-baz qux' },
{ name: 'foo--baz', command: 'npm run foo--baz qux' },
{ name: 'bar', command: 'npm run foo-bar-baz qux' },
{ name: '', command: 'npm run foo--baz qux' },
]);
});

Expand All @@ -52,3 +52,17 @@ it('caches scripts upon calls', () => {

expect(readPkg).toHaveBeenCalledTimes(1);
});

it('suffix name with wildcard values', () => {
readPkg.mockReturnValue({
scripts: {
'watch-foo': '',
'watch-bar': '',
}
});

expect(parser.parse({ name: 'w:', command: 'npm run watch-*' })).toEqual([
{ name: 'w:foo', command: 'npm run watch-foo' },
{ name: 'w:bar', command: 'npm run watch-bar' },
]);
});