Skip to content

Commit 6798df4

Browse files
authored
Fix: fix unknown single-instance type error (#4111)
**Summary** When `:` is not used in the `mutex` argument to provide a specifier, `mutexType` and `mutexSpecifier` are parsed incorrectly. This patch fixes that. **Test plan** Run `yarn --mutex=network` before the patch, observe the error. Run the same command after the patch and see it pass.
1 parent eec75ea commit 6798df4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/cli/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,15 @@ export function main({
356356
const mutex: mixed = commander.mutex;
357357
if (mutex && typeof mutex === 'string') {
358358
const separatorLoc = mutex.indexOf(':');
359-
const mutexType = mutex.substring(0, separatorLoc);
360-
const mutexSpecifier = mutex.substring(separatorLoc + 1);
359+
let mutexType;
360+
let mutexSpecifier;
361+
if (separatorLoc === -1) {
362+
mutexType = mutex;
363+
mutexSpecifier = undefined;
364+
} else {
365+
mutexType = mutex.substring(0, separatorLoc);
366+
mutexSpecifier = mutex.substring(separatorLoc + 1);
367+
}
361368

362369
if (mutexType === 'file') {
363370
return runEventuallyWithFile(mutexSpecifier, true).then(exit);

0 commit comments

Comments
 (0)