Fixed updating yaml from other files

This commit is contained in:
Mike Farah
2021-02-11 10:58:40 +11:00
parent 90d55fb52a
commit 5aff50a345
9 changed files with 108 additions and 23 deletions
+21
View File
@@ -34,6 +34,27 @@ a:
g: foof
```
## Update node from another file
Note this will also work when the second file is a scalar (string/number)
Given a sample.yml file of:
```yaml
a: apples
```
And another sample another.yml file of:
```yaml
b: bob
```
then
```bash
yq eval-all 'select(fileIndex==0).a = select(fileIndex==1) | select(fileIndex==0)' sample.yml another.yml
```
will output
```yaml
a:
b: bob
```
## Update node to be the sibling value
Given a sample.yml file of:
```yaml
+1 -1
View File
@@ -16,7 +16,7 @@ yq eval 'filename' sample.yml
```
will output
```yaml
sample.yaml
sample.yml
```
## Get file index