From 83ec8abe5a021d235a77952748d29d1cbabe7e94 Mon Sep 17 00:00:00 2001
From: Thomas Sileghem
Date: Sat, 22 Sep 2018 11:43:37 +0100
Subject: [PATCH 1/3] fix: use wildcard values as names
---
src/command-parser/expand-npm-wildcard.js | 4 ++--
src/command-parser/expand-npm-wildcard.spec.js | 18 ++++++++++++++++--
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/command-parser/expand-npm-wildcard.js b/src/command-parser/expand-npm-wildcard.js
index 2c9d393f..0b1369af 100644
--- a/src/command-parser/expand-npm-wildcard.js
+++ b/src/command-parser/expand-npm-wildcard.js
@@ -26,9 +26,9 @@ module.exports = class ExpandNpmWildcard {
return this.scripts
.filter(script => wildcardRegex.test(script))
- .map(script => Object.assign({}, commandInfo, {
+ .map(script => Object.assign({}, {
command: `npm run ${script}${args}`,
- name: script
+ name: (commandInfo.names || '') + script.match(wildcardRegex)[1]
}));
}
};
diff --git a/src/command-parser/expand-npm-wildcard.spec.js b/src/command-parser/expand-npm-wildcard.spec.js
index f07a5e6f..a6c37b87 100644
--- a/src/command-parser/expand-npm-wildcard.spec.js
+++ b/src/command-parser/expand-npm-wildcard.spec.js
@@ -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' },
]);
});
@@ -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({ names: 'w:', command: 'npm run watch-*' })).toEqual([
+ { name: 'w:foo', command: 'npm run watch-foo' },
+ { name: 'w:bar', command: 'npm run watch-bar' },
+ ]);
+})
From 59de92b758f4750e6c3a524ea97c9916fff8ebcd Mon Sep 17 00:00:00 2001
From: Thomas Sileghem
Date: Sat, 22 Sep 2018 18:05:26 +0100
Subject: [PATCH 2/3] tweaks
---
src/command-parser/expand-npm-wildcard.js | 2 +-
src/command-parser/expand-npm-wildcard.spec.js | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/command-parser/expand-npm-wildcard.js b/src/command-parser/expand-npm-wildcard.js
index 0b1369af..025f4034 100644
--- a/src/command-parser/expand-npm-wildcard.js
+++ b/src/command-parser/expand-npm-wildcard.js
@@ -28,7 +28,7 @@ module.exports = class ExpandNpmWildcard {
.filter(script => wildcardRegex.test(script))
.map(script => Object.assign({}, {
command: `npm run ${script}${args}`,
- name: (commandInfo.names || '') + script.match(wildcardRegex)[1]
+ name: (commandInfo.name || '') + script.match(wildcardRegex)[1]
}));
}
};
diff --git a/src/command-parser/expand-npm-wildcard.spec.js b/src/command-parser/expand-npm-wildcard.spec.js
index a6c37b87..bd0b178c 100644
--- a/src/command-parser/expand-npm-wildcard.spec.js
+++ b/src/command-parser/expand-npm-wildcard.spec.js
@@ -61,8 +61,8 @@ it('suffix name with wildcard values', () => {
}
});
- expect(parser.parse({ names: 'w:', command: 'npm run watch-*' })).toEqual([
+ 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' },
]);
-})
+});
From a1eb6f078cdfbd6f85e1bb351687c0b4d5987ce1 Mon Sep 17 00:00:00 2001
From: Gustavo Henke
Date: Mon, 24 Sep 2018 00:05:10 +1000
Subject: [PATCH 3/3] Update expand-npm-wildcard.js
---
src/command-parser/expand-npm-wildcard.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/command-parser/expand-npm-wildcard.js b/src/command-parser/expand-npm-wildcard.js
index 025f4034..d0ece2be 100644
--- a/src/command-parser/expand-npm-wildcard.js
+++ b/src/command-parser/expand-npm-wildcard.js
@@ -26,7 +26,7 @@ module.exports = class ExpandNpmWildcard {
return this.scripts
.filter(script => wildcardRegex.test(script))
- .map(script => Object.assign({}, {
+ .map(script => Object.assign({}, commandInfo, {
command: `npm run ${script}${args}`,
name: (commandInfo.name || '') + script.match(wildcardRegex)[1]
}));