| 1 |
# Handle compressed directories |
| 2 |
|
| 3 |
This is an example of how to use transformations (`trans_install` and `trans_update`) to store |
| 4 |
compressed directories and deploy them with dotdrop. |
| 5 |
|
| 6 |
Start by defining the transformations: |
| 7 |
```yaml |
| 8 |
trans_install: |
| 9 |
uncompress: "mkdir -p {1} && tar -xf {0} -C {1}" |
| 10 |
trans_update: |
| 11 |
compress: "tar -cf {1} -C {0} ." |
| 12 |
``` |
| 13 |
|
| 14 |
Then import the directory by specifying which transformations to apply/associate: |
| 15 |
```bash |
| 16 |
dotdrop import --transw=compress --transr=uncompress ~/.somedir |
| 17 |
``` |
| 18 |
|
| 19 |
The *read* transformation `uncompress` is used to execute the below command before installing/comparing the dotfile (where `{0}` is the source and `{1}` the destination): |
| 20 |
```bash |
| 21 |
mkdir -p {1} && tar -xf {0} -C {1} |
| 22 |
``` |
| 23 |
|
| 24 |
And the *write* transformation `compress` is run when updating the dotfile directory by compressing it (where `{0}` is the source and `{1}` the destination): |
| 25 |
```bash |
| 26 |
tar -cf {1} -C {0} . |
| 27 |
``` |
| 28 |
|
| 29 |
See [transformations](../config/config-transformations.md). |