concurrently 6.5.0 → 6.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "concurrently",
3
- "version": "6.5.0",
3
+ "version": "6.5.1",
4
4
  "description": "Run commands concurrently",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -32,12 +32,21 @@ module.exports = class ExpandNpmWildcard {
32
32
  const preWildcard = _.escapeRegExp(cmdName.substr(0, wildcardPosition));
33
33
  const postWildcard = _.escapeRegExp(cmdName.substr(wildcardPosition + 1));
34
34
  const wildcardRegex = new RegExp(`^${preWildcard}(.*?)${postWildcard}$`);
35
+ const currentName = commandInfo.name || '';
35
36
 
36
37
  return this.scripts
37
- .filter(script => wildcardRegex.test(script))
38
- .map(script => Object.assign({}, commandInfo, {
39
- command: `${npmCmd} run ${script}${args}`,
40
- name: script
41
- }));
38
+ .map(script => {
39
+ const match = script.match(wildcardRegex);
40
+
41
+ if (match) {
42
+ return Object.assign({}, commandInfo, {
43
+ command: `${npmCmd} run ${script}${args}`,
44
+ // Will use an empty command name if command has no name and the wildcard match is empty,
45
+ // e.g. if `npm:watch-*` matches `npm run watch-`.
46
+ name: currentName + match[1],
47
+ });
48
+ }
49
+ })
50
+ .filter(Boolean);
42
51
  }
43
52
  };
@@ -71,8 +71,25 @@ for (const npmCmd of ['npm', 'yarn', 'pnpm']) {
71
71
  });
72
72
 
73
73
  expect(parser.parse({ command: `${npmCmd} run foo-*-baz qux` })).toEqual([
74
- { name: 'foo-bar-baz', command: `${npmCmd} run foo-bar-baz qux` },
75
- { name: 'foo--baz', command: `${npmCmd} run foo--baz qux` },
74
+ { name: 'bar', command: `${npmCmd} run foo-bar-baz qux` },
75
+ { name: '', command: `${npmCmd} run foo--baz qux` },
76
+ ]);
77
+ });
78
+
79
+ it('uses existing command name as prefix to the wildcard match', () => {
80
+ readPkg.mockReturnValue({
81
+ scripts: {
82
+ 'watch-js': '',
83
+ 'watch-css': '',
84
+ }
85
+ });
86
+
87
+ expect(parser.parse({
88
+ name: 'w:',
89
+ command: `${npmCmd} run watch-*`,
90
+ })).toEqual([
91
+ { name: 'w:js', command: `${npmCmd} run watch-js` },
92
+ { name: 'w:css', command: `${npmCmd} run watch-css` },
76
93
  ]);
77
94
  });
78
95