feat: Use Raw Text to save if pipeline data is ExternalStream (#7082)
if not value type or Value as String in nushell, save will use raw type
This commit is contained in:
parent
d9d6cea5a9
commit
899383c30c
|
@ -121,6 +121,11 @@ impl Command for Save {
|
||||||
|
|
||||||
let ext = if raw {
|
let ext = if raw {
|
||||||
None
|
None
|
||||||
|
// if is extern stream , in other words , not value
|
||||||
|
} else if let PipelineData::ExternalStream { .. } = input {
|
||||||
|
None
|
||||||
|
} else if let PipelineData::Value(Value::String { .. }, ..) = input {
|
||||||
|
None
|
||||||
} else {
|
} else {
|
||||||
path.extension()
|
path.extension()
|
||||||
.map(|name| name.to_string_lossy().to_string())
|
.map(|name| name.to_string_lossy().to_string())
|
||||||
|
|
|
@ -130,3 +130,22 @@ fn save_stderr_and_stdout_to_diff_file() {
|
||||||
assert!(!actual.contains("bar"));
|
assert!(!actual.contains("bar"));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn save_string_and_stream_as_raw() {
|
||||||
|
Playground::setup("save_test_7", |dirs, sandbox| {
|
||||||
|
sandbox.with_files(vec![]);
|
||||||
|
let expected_file = dirs.test().join("temp.html");
|
||||||
|
nu!(
|
||||||
|
cwd: dirs.root(),
|
||||||
|
r#"
|
||||||
|
`<!DOCTYPE html><html><body><a href='http://example.org/'>Example</a></body></html>` | save save_test_7/temp.html
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
let actual = file_contents(expected_file);
|
||||||
|
assert_eq!(
|
||||||
|
actual,
|
||||||
|
r#"<!DOCTYPE html><html><body><a href='http://example.org/'>Example</a></body></html>"#
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user