mirror of
https://github.com/nushell/nushell
synced 2024-11-10 15:14:14 +00:00
Fix path join on streams (#4959)
This commit is contained in:
parent
2252833917
commit
12b85beecc
2 changed files with 19 additions and 8 deletions
|
@ -5,8 +5,8 @@ use std::{
|
|||
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::{
|
||||
engine::Command, Example, ListStream, PipelineData, ShellError, Signature, Span, Spanned,
|
||||
SyntaxShape, Value,
|
||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape,
|
||||
Value,
|
||||
};
|
||||
|
||||
use super::PathSubcommandArguments;
|
||||
|
@ -63,16 +63,15 @@ the output of 'path parse' and 'path split' subcommands."#
|
|||
append: call.opt(engine_state, stack, 0)?,
|
||||
};
|
||||
|
||||
let metadata = input.metadata();
|
||||
|
||||
match input {
|
||||
PipelineData::Value(val, md) => {
|
||||
Ok(PipelineData::Value(handle_value(val, &args, head), md))
|
||||
}
|
||||
PipelineData::ListStream(stream, md) => Ok(PipelineData::ListStream(
|
||||
ListStream::from_stream(
|
||||
stream.map(move |val| handle_value(val, &args, head)),
|
||||
engine_state.ctrlc.clone(),
|
||||
),
|
||||
md,
|
||||
PipelineData::ListStream(..) => Ok(PipelineData::Value(
|
||||
handle_value(input.into_value(head), &args, head),
|
||||
metadata,
|
||||
)),
|
||||
_ => Err(ShellError::UnsupportedInput(
|
||||
"Input data is not supported by this command.".to_string(),
|
||||
|
|
|
@ -31,6 +31,18 @@ fn returns_path_joined_from_list() {
|
|||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drop_one_path_join() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"[a, b, c] | drop 1 | path join
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["a", "b"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn appends_slash_when_joined_with_empty_path() {
|
||||
let actual = nu!(
|
||||
|
|
Loading…
Reference in a new issue