Skip to content

Patch actions

Similar to the Text actions, the patch actions can be used to update the contents of a file, but you do not need to specify the position of the text to insert. Instead, you need to create a snapshot of the file and a patch file.

A patch works like a git’s diff functionality, but instead of requiring a git branch, the base file is stored as a snapshot in the .demo/snapshots folder, and the patch file is stored in the .demo/patches folder.

Prerequisites of using patch actions

To get started, you first create a snapshot of the file you want to use in your demo. This snapshot will be the starting point for the patches you’ll create.

Follow these steps:

  1. Create a new snapshow by executing the Demo Time: Create a snapshot command from the command palette.
  2. Follow the prompts to give your snapshot a name, and if you want to add it to a new/existing demo.
  1. Once the snapshot is created, apply your changes to the source file.
  2. Once the changes are made, execute the Demo Time: Create a patch command from the command palette.
  3. Follow the prompts to give your patch a name, and if you want to add it to a new/existing demo.

Apply changes

To apply the changes, you can use the applyPatch action. This action takes the path, contentPath, and patch properties as input.

{
"action": "applyPatch",
"path": "<relative path to the file>", // This will be the source file to update
"contentPath": "<relative path to the snapshot file in the .demo folder>",
"patch": "<relative path to the patch file in the .demo folder>"
}