delete-path

Learn how to delete files or directories.

This action deletes a file or directory. If the path does not exist, the action completes silently without error.

Example

The following template cleans up a temporary directory after setup:

template.json5
{  "$schema": "https://schema.croct.com/json/v1/template.json",  "title": "Cleanup",  "description": "Removes the temporary setup directory.",  "actions": [    {      "name": "delete-path",      "path": "temp",      "recursive": true    },    {      "name": "print",      "semantics": "success",      "message": "Cleanup complete."    }  ]}

To apply this template, run:

npx croct@latest use template.json5

Properties

These are the supported properties:

name
string

The action identifier. Always delete-path for this action.

path
string

The path to the file or directory to delete.

recursive(optional)
boolean

Whether to recursively delete the contents of a directory.

Required for non-empty directories.

Default:false