|
742 | 742 | // This builds process.allowedNodeEnvironmentFlags |
743 | 743 | // from data in the config binding |
744 | 744 |
|
745 | | - const replaceDashesRegex = /-/g; |
| 745 | + const replaceUnderscoresRegex = /_/g; |
746 | 746 | const leadingDashesRegex = /^--?/; |
747 | 747 | const trailingValuesRegex = /=.*$/; |
748 | 748 |
|
|
754 | 754 | const get = () => { |
755 | 755 | const { |
756 | 756 | getOptions, |
757 | | - types: { kV8Option }, |
758 | 757 | envSettings: { kAllowedInEnvironment } |
759 | 758 | } = internalBinding('options'); |
760 | 759 | const { options, aliases } = getOptions(); |
761 | 760 |
|
762 | | - const allowedV8EnvironmentFlags = []; |
763 | 761 | const allowedNodeEnvironmentFlags = []; |
764 | 762 | for (const [name, info] of options) { |
765 | 763 | if (info.envVarSettings === kAllowedInEnvironment) { |
766 | | - if (info.type === kV8Option) { |
767 | | - allowedV8EnvironmentFlags.push(name); |
768 | | - } else { |
769 | | - allowedNodeEnvironmentFlags.push(name); |
770 | | - } |
| 764 | + allowedNodeEnvironmentFlags.push(name); |
771 | 765 | } |
772 | 766 | } |
773 | 767 |
|
|
801 | 795 | // process.allowedNodeEnvironmentFlags.has() which lack leading dashes. |
802 | 796 | // Avoid interference w/ user code by flattening `Set.prototype` into |
803 | 797 | // each object. |
804 | | - const [nodeFlags, v8Flags] = [ |
805 | | - allowedNodeEnvironmentFlags, allowedV8EnvironmentFlags |
806 | | - ].map((flags) => Object.defineProperties( |
807 | | - new Set(flags.map(trimLeadingDashes)), |
808 | | - Object.getOwnPropertyDescriptors(Set.prototype)) |
| 798 | + const nodeFlags = Object.defineProperties( |
| 799 | + new Set(allowedNodeEnvironmentFlags.map(trimLeadingDashes)), |
| 800 | + Object.getOwnPropertyDescriptors(Set.prototype) |
809 | 801 | ); |
810 | 802 |
|
811 | 803 | class NodeEnvironmentFlagsSet extends Set { |
|
829 | 821 | has(key) { |
830 | 822 | // This will return `true` based on various possible |
831 | 823 | // permutations of a flag, including present/missing leading |
832 | | - // dash(es) and/or underscores-for-dashes in the case of V8-specific |
833 | | - // flags. Strips any values after `=`, inclusive. |
| 824 | + // dash(es) and/or underscores-for-dashes. |
| 825 | + // Strips any values after `=`, inclusive. |
834 | 826 | // TODO(addaleax): It might be more flexible to run the option parser |
835 | 827 | // on a dummy option set and see whether it rejects the argument or |
836 | 828 | // not. |
837 | 829 | if (typeof key === 'string') { |
838 | | - key = replace(key, trailingValuesRegex, ''); |
| 830 | + key = replace(key, replaceUnderscoresRegex, '-'); |
839 | 831 | if (test(leadingDashesRegex, key)) { |
840 | | - return has(this, key) || |
841 | | - has(v8Flags, |
842 | | - replace( |
843 | | - replace( |
844 | | - key, |
845 | | - leadingDashesRegex, |
846 | | - '' |
847 | | - ), |
848 | | - replaceDashesRegex, |
849 | | - '_' |
850 | | - ) |
851 | | - ); |
| 832 | + key = replace(key, trailingValuesRegex, ''); |
| 833 | + return has(this, key); |
852 | 834 | } |
853 | | - return has(nodeFlags, key) || |
854 | | - has(v8Flags, replace(key, replaceDashesRegex, '_')); |
| 835 | + return has(nodeFlags, key); |
855 | 836 | } |
856 | 837 | return false; |
857 | 838 | } |
|
862 | 843 |
|
863 | 844 | return process.allowedNodeEnvironmentFlags = Object.freeze( |
864 | 845 | new NodeEnvironmentFlagsSet( |
865 | | - allowedNodeEnvironmentFlags.concat(allowedV8EnvironmentFlags) |
| 846 | + allowedNodeEnvironmentFlags |
866 | 847 | )); |
867 | 848 | }; |
868 | 849 |
|
|
0 commit comments