Fix custom converters with save (#12833)

# Description
Fixes #10429 where `save` fails if a custom command is used as the file
format converter.

# Tests + Formatting
Added a test.
This commit is contained in:
Ian Manske
2024-05-12 11:19:28 +00:00
committed by GitHub
parent 075535f869
commit 30fc832035
2 changed files with 36 additions and 22 deletions

View File

@ -407,3 +407,20 @@ fn save_same_file_without_extension_pipeline() {
.contains("pipeline input and output are the same file"));
})
}
#[test]
fn save_with_custom_converter() {
Playground::setup("save_with_custom_converter", |dirs, _| {
let file = dirs.test().join("test.ndjson");
nu!(cwd: dirs.test(), pipeline(
r#"
def "to ndjson" []: any -> string { each { to json --raw } | to text } ;
{a: 1, b: 2} | save test.ndjson
"#
));
let actual = file_contents(file);
assert_eq!(actual, r#"{"a":1,"b":2}"#);
})
}