|
620 | 620 | consttest=Function.call.bind(RegExp.prototype.test); |
621 | 621 |
|
622 | 622 | const{ |
623 | | - allowedV8EnvironmentFlags, |
624 | | - allowedNodeEnvironmentFlags |
625 | | -}=process.binding('config'); |
| 623 | + getOptions, |
| 624 | +types: { kV8Option }, |
| 625 | +envSettings: { kAllowedInEnvironment } |
| 626 | +}=internalBinding('options'); |
| 627 | +const{ options, aliases }=getOptions(); |
| 628 | + |
| 629 | +constallowedV8EnvironmentFlags=[]; |
| 630 | +constallowedNodeEnvironmentFlags=[]; |
| 631 | +for(const[name,info]ofoptions){ |
| 632 | +if(info.envVarSettings===kAllowedInEnvironment){ |
| 633 | +if(info.type===kV8Option){ |
| 634 | +allowedV8EnvironmentFlags.push(name); |
| 635 | +}else{ |
| 636 | +allowedNodeEnvironmentFlags.push(name); |
| 637 | +} |
| 638 | +} |
| 639 | +} |
| 640 | + |
| 641 | +for(const[from,expansion]ofaliases){ |
| 642 | +letisAccepted=true; |
| 643 | +for(consttoofexpansion){ |
| 644 | +if(!to.startsWith('-'))continue; |
| 645 | +constrecursiveExpansion=aliases.get(to); |
| 646 | +if(recursiveExpansion){ |
| 647 | +expansion.push(...recursiveExpansion); |
| 648 | +continue; |
| 649 | +} |
| 650 | +isAccepted=options.get(to).envVarSettings===kAllowedInEnvironment; |
| 651 | +if(!isAccepted)break; |
| 652 | +} |
| 653 | +if(isAccepted){ |
| 654 | +letcanonical=from; |
| 655 | +if(canonical.endsWith('=')) |
| 656 | +canonical=canonical.substr(0,canonical.length-1); |
| 657 | +if(canonical.endsWith(' <arg>')) |
| 658 | +canonical=canonical.substr(0,canonical.length-4); |
| 659 | +allowedNodeEnvironmentFlags.push(canonical); |
| 660 | +} |
| 661 | +} |
626 | 662 |
|
627 | 663 | consttrimLeadingDashes=(flag)=>replace(flag,leadingDashesRegex,''); |
628 | 664 |
|
|
660 | 696 | // permutations of a flag, including present/missing leading |
661 | 697 | // dash(es) and/or underscores-for-dashes in the case of V8-specific |
662 | 698 | // flags. Strips any values after `=`, inclusive. |
| 699 | +// TODO(addaleax): It might be more flexible to run the option parser |
| 700 | +// on a dummy option set and see whether it rejects the argument or |
| 701 | +// not. |
663 | 702 | if(typeofkey==='string'){ |
664 | 703 | key=replace(key,trailingValuesRegex,''); |
665 | 704 | if(test(leadingDashesRegex,key)){ |
|
0 commit comments