Skip to content

Commit

Permalink
feat(protocol-designer): indent generated JSON file to make it readab…
Browse files Browse the repository at this point in the history
…le (#17086)

# Overview

I have to stare at JSON protocols a lot. Indenting them makes them
easier to read, and saves me the trouble of using a separate tool just
to reformat the JSON.

`JSON.stringify()` has a built-in option for indentation; we just have
to call it.

## Test Plan and Hands on Testing

I edited a protocol in PD and examined the generated JSON file by hand.

I confirmed that the indented JSON files can be successfully
re-imported.

All the CI tests pass.

## Risk assessment

Low risk. The indented JSON files should be entirely semantically
equivalent to the unindented ones.
  • Loading branch information
ddcc4 authored Dec 11, 2024
1 parent 96fc13e commit 89941ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion protocol-designer/src/load-file/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { saveAs } from 'file-saver'
import type { ProtocolFile } from '@opentrons/shared-data'
export const saveFile = (fileData: ProtocolFile, fileName: string): void => {
const blob = new Blob([JSON.stringify(fileData)], {
const blob = new Blob([JSON.stringify(fileData, null, 2)], {
type: 'application/json',
})
saveAs(blob, fileName)
Expand Down

0 comments on commit 89941ea

Please sign in to comment.