mirror of
https://github.com/nushell/nushell.git
synced 2025-02-02 19:50:05 +01:00
Fix path join on streams (#4959)
This commit is contained in:
parent
2252833917
commit
12b85beecc
@ -5,8 +5,8 @@ use std::{
|
|||||||
|
|
||||||
use nu_engine::CallExt;
|
use nu_engine::CallExt;
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, ListStream, PipelineData, ShellError, Signature, Span, Spanned,
|
engine::Command, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape,
|
||||||
SyntaxShape, Value,
|
Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
use super::PathSubcommandArguments;
|
||||||
@ -63,16 +63,15 @@ the output of 'path parse' and 'path split' subcommands."#
|
|||||||
append: call.opt(engine_state, stack, 0)?,
|
append: call.opt(engine_state, stack, 0)?,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let metadata = input.metadata();
|
||||||
|
|
||||||
match input {
|
match input {
|
||||||
PipelineData::Value(val, md) => {
|
PipelineData::Value(val, md) => {
|
||||||
Ok(PipelineData::Value(handle_value(val, &args, head), md))
|
Ok(PipelineData::Value(handle_value(val, &args, head), md))
|
||||||
}
|
}
|
||||||
PipelineData::ListStream(stream, md) => Ok(PipelineData::ListStream(
|
PipelineData::ListStream(..) => Ok(PipelineData::Value(
|
||||||
ListStream::from_stream(
|
handle_value(input.into_value(head), &args, head),
|
||||||
stream.map(move |val| handle_value(val, &args, head)),
|
metadata,
|
||||||
engine_state.ctrlc.clone(),
|
|
||||||
),
|
|
||||||
md,
|
|
||||||
)),
|
)),
|
||||||
_ => Err(ShellError::UnsupportedInput(
|
_ => Err(ShellError::UnsupportedInput(
|
||||||
"Input data is not supported by this command.".to_string(),
|
"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);
|
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]
|
#[test]
|
||||||
fn appends_slash_when_joined_with_empty_path() {
|
fn appends_slash_when_joined_with_empty_path() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
Loading…
Reference in New Issue
Block a user