28 lines
837 B
JavaScript
Executable File
28 lines
837 B
JavaScript
Executable File
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.findOption = void 0;
|
|
/**
|
|
* A utility function to find an option in the AST
|
|
*
|
|
* @param nodes AST node list
|
|
* @param opts Long and short names to look up
|
|
*/
|
|
function findOption(nodes, opts) {
|
|
const result = [];
|
|
for (const node of nodes) {
|
|
if (node.type === 'longOption' && opts.longNames.includes(node.key)) {
|
|
result.push(node);
|
|
continue;
|
|
}
|
|
if (node.type === 'shortOptions' && opts.shortNames.length) {
|
|
for (const option of node.options) {
|
|
if (opts.shortNames.includes(option.key)) {
|
|
result.push(option);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
exports.findOption = findOption;
|
|
//# sourceMappingURL=findOption.js.map
|