Improve rustdoc-js tester code clarity a bit

This commit is contained in:
Guillaume Gomez 2023-03-11 21:40:17 +01:00
parent 856c9bb481
commit 904d9c5c54

View file

@ -361,22 +361,24 @@ function parseOptions(args) {
}; };
for (let i = 0; i < args.length; ++i) { for (let i = 0; i < args.length; ++i) {
if (Object.prototype.hasOwnProperty.call(correspondences, args[i])) { const arg = args[i];
if (Object.prototype.hasOwnProperty.call(correspondences, arg)) {
i += 1; i += 1;
if (i >= args.length) { if (i >= args.length) {
console.log("Missing argument after `" + args[i - 1] + "` option."); console.log("Missing argument after `" + arg + "` option.");
return null; return null;
} }
if (args[i - 1] !== "--test-file") { const arg_value = args[i];
opts[correspondences[args[i - 1]]] = args[i]; if (arg !== "--test-file") {
opts[correspondences[arg]] = arg_value;
} else { } else {
opts[correspondences[args[i - 1]]].push(args[i]); opts[correspondences[arg]].push(arg_value);
} }
} else if (args[i] === "--help") { } else if (arg === "--help") {
showHelp(); showHelp();
process.exit(0); process.exit(0);
} else { } else {
console.log("Unknown option `" + args[i] + "`."); console.log("Unknown option `" + arg + "`.");
console.log("Use `--help` to see the list of options"); console.log("Use `--help` to see the list of options");
return null; return null;
} }