Skip to content

Commit

Permalink
Delete unreachable code and add specs for boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alhadis committed Sep 2, 2019
1 parent 8678ef3 commit 6f47e3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/utils/general.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ export function splitOptions(argv, niladicShort = "", monadicShort = "", monadic
const undash = x => x.replace(/-|\s/g, "");
niladicShort = escape(undash(niladicShort));
monadicShort = escape(undash(monadicShort));
monadicLong = monadicLong.split("|").filter(Boolean).map(escape).sort((a, b) =>
b.indexOf(a) ? a.indexOf(b) ? a.localeCompare(b) : -1 : 1).join("|");
monadicLong = monadicLong.split("|").filter(Boolean).map(escape).sort().join("|");
const patterns = [
niladicShort && new RegExp(`^-([${niladicShort}][^-\\s${monadicShort}]*)${
monadicShort ? `(?:([${monadicShort}])(\\S+)?)?` : "(\\S*)"}`),
Expand Down
5 changes: 5 additions & 0 deletions test/1.1-general.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,5 +931,10 @@ describe("General-purpose", () => {
expect(splitOptions(null)).to.eql([]);
expect(splitOptions(false)).to.eql([]);
});

it("boxes string arguments into arrays", () => {
expect(splitOptions("-abc", "abc")).to.eql(["-a", "-b", "-c"]);
expect(splitOptions("-abc", "a", "bc")).to.eql(["-a", "-b", "c"]);
});
});
});

0 comments on commit 6f47e3c

Please sign in to comment.