|
616 | 616 | // This builds process.allowedNodeEnvironmentFlags |
617 | 617 | // from data in the config binding |
618 | 618 |
|
619 | | -constreplaceDashesRegex=/-/g; |
| 619 | +constreplaceUnderscoresRegex=/_/g; |
620 | 620 | constleadingDashesRegex=/^--?/; |
621 | 621 | consttrailingValuesRegex=/=.*$/; |
622 | 622 |
|
|
628 | 628 | constget=()=>{ |
629 | 629 | const{ |
630 | 630 | getOptions, |
631 | | -types: { kV8Option }, |
632 | 631 | envSettings: { kAllowedInEnvironment } |
633 | 632 | }=internalBinding('options'); |
634 | 633 | const{ options, aliases }=getOptions(); |
635 | 634 |
|
636 | | -constallowedV8EnvironmentFlags=[]; |
637 | 635 | constallowedNodeEnvironmentFlags=[]; |
638 | 636 | for(const[name,info]ofoptions){ |
639 | 637 | if(info.envVarSettings===kAllowedInEnvironment){ |
640 | | -if(info.type===kV8Option){ |
641 | | -allowedV8EnvironmentFlags.push(name); |
642 | | -}else{ |
643 | | -allowedNodeEnvironmentFlags.push(name); |
644 | | -} |
| 638 | +allowedNodeEnvironmentFlags.push(name); |
645 | 639 | } |
646 | 640 | } |
647 | 641 |
|
|
675 | 669 | // process.allowedNodeEnvironmentFlags.has() which lack leading dashes. |
676 | 670 | // Avoid interference w/ user code by flattening `Set.prototype` into |
677 | 671 | // each object. |
678 | | -const[nodeFlags,v8Flags]=[ |
679 | | -allowedNodeEnvironmentFlags,allowedV8EnvironmentFlags |
680 | | -].map((flags)=>Object.defineProperties( |
681 | | -newSet(flags.map(trimLeadingDashes)), |
682 | | -Object.getOwnPropertyDescriptors(Set.prototype)) |
| 672 | +constnodeFlags=Object.defineProperties( |
| 673 | +newSet(allowedNodeEnvironmentFlags.map(trimLeadingDashes)), |
| 674 | +Object.getOwnPropertyDescriptors(Set.prototype) |
683 | 675 | ); |
684 | 676 |
|
685 | 677 | classNodeEnvironmentFlagsSetextendsSet{ |
|
703 | 695 | has(key){ |
704 | 696 | // This will return `true` based on various possible |
705 | 697 | // permutations of a flag, including present/missing leading |
706 | | -// dash(es) and/or underscores-for-dashes in the case of V8-specific |
707 | | -// flags. Strips any values after `=`, inclusive. |
| 698 | +// dash(es) and/or underscores-for-dashes. |
| 699 | +// Strips any values after `=`, inclusive. |
708 | 700 | // TODO(addaleax): It might be more flexible to run the option parser |
709 | 701 | // on a dummy option set and see whether it rejects the argument or |
710 | 702 | // not. |
711 | 703 | if(typeofkey==='string'){ |
712 | | -key=replace(key,trailingValuesRegex,''); |
| 704 | +key=replace(key,replaceUnderscoresRegex,'-'); |
713 | 705 | if(test(leadingDashesRegex,key)){ |
714 | | -returnhas(this,key)|| |
715 | | -has(v8Flags, |
716 | | -replace( |
717 | | -replace( |
718 | | -key, |
719 | | -leadingDashesRegex, |
720 | | -'' |
721 | | -), |
722 | | -replaceDashesRegex, |
723 | | -'_' |
724 | | -) |
725 | | -); |
| 706 | +key=replace(key,trailingValuesRegex,''); |
| 707 | +returnhas(this,key); |
726 | 708 | } |
727 | | -returnhas(nodeFlags,key)|| |
728 | | -has(v8Flags,replace(key,replaceDashesRegex,'_')); |
| 709 | +returnhas(nodeFlags,key); |
729 | 710 | } |
730 | 711 | returnfalse; |
731 | 712 | } |
|
736 | 717 |
|
737 | 718 | returnprocess.allowedNodeEnvironmentFlags=Object.freeze( |
738 | 719 | newNodeEnvironmentFlagsSet( |
739 | | -allowedNodeEnvironmentFlags.concat(allowedV8EnvironmentFlags) |
| 720 | +allowedNodeEnvironmentFlags |
740 | 721 | )); |
741 | 722 | }; |
742 | 723 |
|
|
0 commit comments