A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/8ea1fc5f3b below:

support namespace options in configuration file · nodejs/node@8ea1fc5 · GitHub

@@ -13,6 +13,7 @@ const {

13 13

getCLIOptionsInfo,

14 14

getEmbedderOptions: getEmbedderOptionsFromBinding,

15 15

getEnvOptionsInputType,

16 +

getNamespaceOptionsInputType,

16 17

} = internalBinding('options');

17 18 18 19

let warnOnAllowUnauthorized = true;

@@ -38,7 +39,22 @@ function getEmbedderOptions() {

38 39

}

39 40 40 41

function generateConfigJsonSchema() {

41 -

const map = getEnvOptionsInputType();

42 +

const envOptionsMap = getEnvOptionsInputType();

43 +

const namespaceOptionsMap = getNamespaceOptionsInputType();

44 + 45 +

function createPropertyForType(type) {

46 +

if (type === 'array') {

47 +

return {

48 +

__proto__: null,

49 +

oneOf: [

50 +

{ __proto__: null, type: 'string' },

51 +

{ __proto__: null, items: { __proto__: null, type: 'string', minItems: 1 }, type: 'array' },

52 +

],

53 +

};

54 +

}

55 + 56 +

return { __proto__: null, type };

57 +

}

42 58 43 59

const schema = {

44 60

__proto__: null,

@@ -60,31 +76,58 @@ function generateConfigJsonSchema() {

60 76

type: 'object',

61 77

};

62 78 63 -

const nodeOptions = schema.properties.nodeOptions.properties;

79 +

// Get the root properties object for adding namespaces

80 +

const rootProperties = schema.properties;

81 +

const nodeOptions = rootProperties.nodeOptions.properties;

64 82 65 -

for (const { 0: key, 1: type } of map) {

83 +

// Add env options to nodeOptions (backward compatibility)

84 +

for (const { 0: key, 1: type } of envOptionsMap) {

66 85

const keyWithoutPrefix = StringPrototypeReplace(key, '--', '');

67 -

if (type === 'array') {

68 -

nodeOptions[keyWithoutPrefix] = {

69 -

__proto__: null,

70 -

oneOf: [

71 -

{ __proto__: null, type: 'string' },

72 -

{ __proto__: null, items: { __proto__: null, type: 'string', minItems: 1 }, type: 'array' },

73 -

],

74 -

};

75 -

} else {

76 -

nodeOptions[keyWithoutPrefix] = { __proto__: null, type };

86 +

nodeOptions[keyWithoutPrefix] = createPropertyForType(type);

87 +

}

88 + 89 +

// Add namespace properties at the root level

90 +

for (const { 0: namespace, 1: optionsMap } of namespaceOptionsMap) {

91 +

// Create namespace object at the root level

92 +

rootProperties[namespace] = {

93 +

__proto__: null,

94 +

type: 'object',

95 +

additionalProperties: false,

96 +

properties: { __proto__: null },

97 +

};

98 + 99 +

const namespaceProperties = rootProperties[namespace].properties;

100 + 101 +

// Add all options for this namespace

102 +

for (const { 0: optionName, 1: optionType } of optionsMap) {

103 +

const keyWithoutPrefix = StringPrototypeReplace(optionName, '--', '');

104 +

namespaceProperties[keyWithoutPrefix] = createPropertyForType(optionType);

77 105

}

106 + 107 +

// Sort the namespace properties alphabetically

108 +

const sortedNamespaceKeys = ArrayPrototypeSort(ObjectKeys(namespaceProperties));

109 +

const sortedNamespaceProperties = ObjectFromEntries(

110 +

ArrayPrototypeMap(sortedNamespaceKeys, (key) => [key, namespaceProperties[key]]),

111 +

);

112 +

rootProperties[namespace].properties = sortedNamespaceProperties;

78 113

}

79 114 80 -

// Sort the proerties by key alphabetically.

115 +

// Sort the top-level properties by key alphabetically

81 116

const sortedKeys = ArrayPrototypeSort(ObjectKeys(nodeOptions));

82 117

const sortedProperties = ObjectFromEntries(

83 118

ArrayPrototypeMap(sortedKeys, (key) => [key, nodeOptions[key]]),

84 119

);

85 120 86 121

schema.properties.nodeOptions.properties = sortedProperties;

87 122 123 +

// Also sort the root level properties

124 +

const sortedRootKeys = ArrayPrototypeSort(ObjectKeys(rootProperties));

125 +

const sortedRootProperties = ObjectFromEntries(

126 +

ArrayPrototypeMap(sortedRootKeys, (key) => [key, rootProperties[key]]),

127 +

);

128 + 129 +

schema.properties = sortedRootProperties;

130 + 88 131

return schema;

89 132

}

90 133

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4