MCPcopy Index your code
hub / github.com/bombshell-dev/clack / updateSettings

Function updateSettings

packages/core/src/utils/settings.ts:118–171  ·  view source on GitHub ↗
(updates: ClackSettings)

Source from the content-addressed store, hash-verified

116}
117
118export function updateSettings(updates: ClackSettings) {
119 // Handle each property in the updates
120 if (updates.aliases !== undefined) {
121 const aliases = updates.aliases;
122 for (const alias in aliases) {
123 if (!Object.hasOwn(aliases, alias)) continue;
124
125 const action = aliases[alias];
126 if (!settings.actions.has(action)) continue;
127
128 if (!settings.aliases.has(alias)) {
129 settings.aliases.set(alias, action);
130 }
131 }
132 }
133
134 if (updates.messages !== undefined) {
135 const messages = updates.messages;
136 if (messages.cancel !== undefined) {
137 settings.messages.cancel = messages.cancel;
138 }
139 if (messages.error !== undefined) {
140 settings.messages.error = messages.error;
141 }
142 }
143
144 if (updates.withGuide !== undefined) {
145 settings.withGuide = updates.withGuide !== false;
146 }
147
148 if (updates.date !== undefined) {
149 const date = updates.date;
150 if (date.monthNames !== undefined) {
151 settings.date.monthNames = [...date.monthNames];
152 }
153 if (date.messages !== undefined) {
154 if (date.messages.required !== undefined) {
155 settings.date.messages.required = date.messages.required;
156 }
157 if (date.messages.invalidMonth !== undefined) {
158 settings.date.messages.invalidMonth = date.messages.invalidMonth;
159 }
160 if (date.messages.invalidDay !== undefined) {
161 settings.date.messages.invalidDay = date.messages.invalidDay;
162 }
163 if (date.messages.afterMin !== undefined) {
164 settings.date.messages.afterMin = date.messages.afterMin;
165 }
166 if (date.messages.beforeMax !== undefined) {
167 settings.date.messages.beforeMax = date.messages.beforeMax;
168 }
169 }
170 }
171}
172
173/**
174 * Check if a key is an alias for a default action

Callers 10

date.test.tsFile · 0.90
box.test.tsFile · 0.90
spinner.test.tsFile · 0.90
password.test.tsFile · 0.90
select-key.test.tsFile · 0.90
text.test.tsFile · 0.90
multi-line.test.tsFile · 0.90
select.test.tsFile · 0.90
confirm.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected