MCPcopy Create free account
hub / github.com/formkit/formkit / editTheme

Function editTheme

packages/cli/src/theme.ts:251–279  ·  view source on GitHub ↗
(
  path: string,
  code: string,
  checksum: string,
  variables: string,
  theme: string
)

Source from the content-addressed store, hash-verified

249}
250
251async function editTheme(
252 path: string,
253 code: string,
254 checksum: string,
255 variables: string,
256 theme: string
257) {
258 const codeWithoutChecksum = code.replace(
259 `* @checksum - ${checksum}`,
260 '* @checksum -'
261 )
262 const newChecksum = createHash('sha256')
263 .update(codeWithoutChecksum)
264 .digest('hex')
265 if (newChecksum !== checksum) {
266 const { confirm } = await prompts({
267 type: 'confirm',
268 message:
269 'It appears you’ve edited your theme file. By continuing any changes made to your theme file will be lost. Are you sure you want to continue?',
270 name: 'confirm',
271 initial: false,
272 })
273
274 if (!confirm) {
275 return error('Aborting.')
276 }
277 }
278 await editMode(theme, variables, path)
279}
280
281/**
282 * Use the public formkit url shortener.

Callers 1

buildThemeFunction · 0.85

Calls 2

errorFunction · 0.90
editModeFunction · 0.85

Tested by

no test coverage detected