Skip to content

Commit

Permalink
document escapeJSON datastore helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj committed Nov 4, 2024
1 parent bcbc1fd commit 4ec7f60
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/cli-test/src/cli/commands/datastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export interface DatastoreCommandArguments {
queryExpressionValues: object;
}

/**
* Used to escape double quotes in JSON strings; this is needed when JSON is passed as a command line argument, which for the datastore commands, it is.
*/
function escapeJSON(obj: Record<string, unknown>): string {
return `"${JSON.stringify(obj).replace(/"/g, '\\"')}"`;
}
Expand Down

0 comments on commit 4ec7f60

Please sign in to comment.