Skip to content

Commit

Permalink
Fix traverse script after yargs upgrade
Browse files Browse the repository at this point in the history
mdn#11916 broke the traverse
script, probably due to yargs/yargs#1992.

The problem now is that for `npm run chrome all 90`, `values`
will be ["null", "true", "90"], due to the combining of default and
given argument, where before `values` would have been ["90"].

We were using arrays for both folder and value, which doesn't really
make sense since only the last positional argument can be variadic:
https://github.com/yargs/yargs/blob/master/docs/advanced.md#variadic-positional-arguments

Since we use comma-separated values, just use strings instead to avoid
the problem.
  • Loading branch information
foolip committed Aug 12, 2021
1 parent 3cd7e38 commit 15872ae
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions scripts/traverse.js
Expand Up @@ -12,13 +12,13 @@ const { argv } = require('yargs').command(
})
.positional('folder', {
describe: 'The folder(s) to test (set to "all" for all folders)',
type: 'array',
type: 'string',
default: 'all',
})
.positional('value', {
describe: 'The value(s) to test against',
type: 'array',
default: ['null', 'true'],
type: 'string',
default: 'null,true',
})
.option('depth', {
alias: 'd',
Expand Down Expand Up @@ -79,9 +79,7 @@ const folders =
'xslt',
]
: argv.folder.split(',');
const values = Array.isArray(argv.value)
? argv.value
: argv.value.toString().split(',');
const values = argv.value.split(',');

for (const folder in folders)
traverseFeatures(bcd[folders[folder]], argv.depth, `${folders[folder]}.`);
Expand Down

0 comments on commit 15872ae

Please sign in to comment.