Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/command-parser/expand-npm-wildcard.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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' },
]);
});