Skip to content

Commit fa545b1

Browse files
committed
outputs: add trailing \n at the end of json files
Signed-off-by: Sebastien Duthil <[email protected]>
1 parent 422c397 commit fa545b1

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

functional-tests/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,8 @@ bar: |-
11681168
r#"{
11691169
"foo": "bar",
11701170
"bar": "baz\nbam"
1171-
}"#
1171+
}
1172+
"#
11721173
);
11731174
}
11741175

stores/json/store.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ func (store *Store) EmitEncryptedFile(in sops.Tree) ([]byte, error) {
326326
if err != nil {
327327
return nil, fmt.Errorf("Error marshaling to json: %s", err)
328328
}
329+
out = append(out, '\n')
329330
return out, nil
330331
}
331332

@@ -336,6 +337,7 @@ func (store *Store) EmitPlainFile(in sops.TreeBranches) ([]byte, error) {
336337
if err != nil {
337338
return nil, fmt.Errorf("Error marshaling to json: %s", err)
338339
}
340+
out = append(out, '\n')
339341
return out, nil
340342
}
341343

stores/json/store_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func TestDecodeJSON(t *testing.T) {
3434
}
3535
}
3636
}
37-
}`
37+
}
38+
`
3839
expected := sops.TreeBranch{
3940
sops.TreeItem{
4041
Key: "glossary",
@@ -312,7 +313,8 @@ func TestEncodeJSONArrayOfObjects(t *testing.T) {
312313
},
313314
2
314315
]
315-
}`
316+
}
317+
`
316318
store := Store{
317319
config: config.JSONStoreConfig{
318320
Indent: -1,
@@ -446,7 +448,8 @@ func TestIndentTwoSpaces(t *testing.T) {
446448
},
447449
2
448450
]
449-
}`
451+
}
452+
`
450453
store := Store{
451454
config: config.JSONStoreConfig{
452455
Indent: 2,
@@ -488,7 +491,8 @@ func TestIndentDefault(t *testing.T) {
488491
},
489492
2
490493
]
491-
}`
494+
}
495+
`
492496
store := Store{
493497
config: config.JSONStoreConfig{
494498
Indent: -1,
@@ -530,7 +534,8 @@ func TestNoIndent(t *testing.T) {
530534
},
531535
2
532536
]
533-
}`
537+
}
538+
`
534539
store := Store{
535540
config: config.JSONStoreConfig{
536541
Indent: 0,

0 commit comments

Comments
 (0)