Skip to content

Commit

Permalink
Revert timeout and slow as string flags so that they can accept human…
Browse files Browse the repository at this point in the history
… readable values

Signed-off-by: Dinika Saxena <[email protected]>
  • Loading branch information
Dinika committed Dec 5, 2024
1 parent 912bdd1 commit 163dd91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/cli/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const nargOpts = types.array
* @ignore
*/
const createErrorForNumericPositionalArg = (
allArgs,
numericArg,
allArgs,
parsedResult
) => {
// A flag for `numericArg` exists if:
Expand All @@ -124,7 +124,7 @@ const createErrorForNumericPositionalArg = (
return (
isMochaFlag(arg) &&
allArgs[index + 1] === String(numericArg) &&
parsedResult[normalizedArg] !== numericArg
parsedResult[normalizedArg] !== String(numericArg)
);
});

Expand Down Expand Up @@ -157,7 +157,7 @@ const parse = (args = [], defaultValues = {}, ...configObjects) => {
// are ALL boolean flags.
// 4. we can then reapply the values after yargs-parser is done.
const allArgs = Array.isArray(args) ? args : args.split(' ');
const nodeArgs = allArgs.reduce((acc, arg, index, allArgs) => {
const nodeArgs = allArgs.reduce((acc, arg) => {
const pair = arg.split('=');
let flag = pair[0];
if (isNodeFlag(flag, false)) {
Expand Down Expand Up @@ -187,8 +187,8 @@ const parse = (args = [], defaultValues = {}, ...configObjects) => {
const numericPositionalArg = result.argv._.find(arg => isNumeric(arg));
if (numericPositionalArg) {
createErrorForNumericPositionalArg(
allArgs,
numericPositionalArg,
allArgs,
result.argv
);
}
Expand Down
15 changes: 12 additions & 3 deletions lib/cli/run-option-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,17 @@ const TYPES = (exports.types = {
'sort',
'watch'
],
number: ['retries', 'jobs', 'slow', 'timeout'],
string: ['config', 'fgrep', 'grep', 'package', 'reporter', 'ui']
number: ['retries', 'jobs'],
string: [
'config',
'fgrep',
'grep',
'package',
'reporter',
'ui',
'slow',
'timeout'
]
});

/**
Expand Down Expand Up @@ -108,7 +117,7 @@ exports.isMochaFlag = flag => {

/**
* Returns expected yarg option type for a given mocha flag.
* @param {string} flag - Flag to check (can be with out without leading "--"")
* @param {string} flag - Flag to check (can be with or without leading dashes "--"")
* @returns {string | undefined} - If flag is a valid mocha flag, the expected type of argument for this flag is returned, otherwise undefined is returned.
* @private
*/
Expand Down
2 changes: 1 addition & 1 deletion test/node-unit/cli/options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ describe('options', function () {
loadOptions('--timeout 500'),
'to have property',
'timeout',
500
'500'
);
});

Expand Down

0 comments on commit 163dd91

Please sign in to comment.