-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: switch type:string option arguments to greedy, but with error …
…for suspect cases in strict mode (#88)
- Loading branch information
1 parent
3643338
commit c2b5e72
Showing
5 changed files
with
269 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
'use strict'; | ||
/* eslint max-len: 0 */ | ||
|
||
const test = require('tape'); | ||
const { isOptionLikeValue } = require('../utils.js'); | ||
|
||
// Basically rejecting values starting with a dash, but run through the interesting possibilities. | ||
|
||
test('isOptionLikeValue: when passed plain text then returns false', (t) => { | ||
t.false(isOptionLikeValue('abc')); | ||
t.end(); | ||
}); | ||
|
||
test('isOptionLikeValue: when passed digits then returns false', (t) => { | ||
t.false(isOptionLikeValue(123)); | ||
t.end(); | ||
}); | ||
|
||
test('isOptionLikeValue: when passed empty string then returns false', (t) => { | ||
t.false(isOptionLikeValue('')); | ||
t.end(); | ||
}); | ||
|
||
// Special case, used as stdin/stdout et al and not reason to reject | ||
test('isOptionLikeValue: when passed dash then returns false', (t) => { | ||
t.false(isOptionLikeValue('-')); | ||
t.end(); | ||
}); | ||
|
||
test('isOptionLikeValue: when passed -- then returns true', (t) => { | ||
// Not strictly option-like, but is supect | ||
t.true(isOptionLikeValue('--')); | ||
t.end(); | ||
}); | ||
|
||
// Supporting undefined so can pass element off end of array without checking | ||
test('isOptionLikeValue: when passed undefined then returns false', (t) => { | ||
t.false(isOptionLikeValue(undefined)); | ||
t.end(); | ||
}); | ||
|
||
test('isOptionLikeValue: when passed short option then returns true', (t) => { | ||
t.true(isOptionLikeValue('-a')); | ||
t.end(); | ||
}); | ||
|
||
test('isOptionLikeValue: when passed short option digit then returns true', (t) => { | ||
t.true(isOptionLikeValue('-1')); | ||
t.end(); | ||
}); | ||
|
||
test('isOptionLikeValue: when passed negative number then returns true', (t) => { | ||
t.true(isOptionLikeValue('-123')); | ||
t.end(); | ||
}); | ||
|
||
test('isOptionLikeValue: when passed short option group of short option with value then returns true', (t) => { | ||
t.true(isOptionLikeValue('-abd')); | ||
t.end(); | ||
}); | ||
|
||
test('isOptionLikeValue: when passed long option then returns true', (t) => { | ||
t.true(isOptionLikeValue('--foo')); | ||
t.end(); | ||
}); | ||
|
||
test('isOptionLikeValue: when passed long option with value then returns true', (t) => { | ||
t.true(isOptionLikeValue('--foo=bar')); | ||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters