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: bugfix for wildcard naming #212

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 13 additions & 5 deletions src/command-parser/expand-npm-wildcard.js
Expand Up @@ -25,10 +25,18 @@ module.exports = class ExpandNpmWildcard {
const wildcardRegex = new RegExp(`^${preWildcard}(.*?)${postWildcard}$`);

return this.scripts
.filter(script => wildcardRegex.test(script))
.map(script => Object.assign({}, commandInfo, {
command: `${npmCmd} run ${script}${args}`,
name: script
}));
.map(script => {
const match = script.match(wildcardRegex);

if (match) {
return Object.assign({}, commandInfo, {
command: `${npmCmd} run ${script}${args}`,
// Use the wildcard portion of the script match unless it's empty,
// in which case use the full name of the script
name: match[1] || script
});
}
})
.filter(Boolean);
}
};
2 changes: 1 addition & 1 deletion src/command-parser/expand-npm-wildcard.spec.js
Expand Up @@ -42,7 +42,7 @@ for (const npmCmd of ['npm', 'yarn']) {
});

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