( path: string, code: string, checksum: string, variables: string, theme: string )
| 249 | } |
| 250 | |
| 251 | async 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. |
no test coverage detected