Skip to content

Commit

Permalink
run fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
prsabahrami committed Sep 8, 2024
1 parent 9224afb commit 6fc25ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
43 changes: 22 additions & 21 deletions crates/deno_task_shell/src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2024 the Deno authors. MIT license.

use anyhow::{anyhow, Result, Context};
use anyhow::{anyhow, Context, Result};
use pest::iterators::Pair;
use pest::Parser;
use pest_derive::Parser;
Expand Down Expand Up @@ -909,28 +909,29 @@ fn parse_env_var(pair: Pair<Rule>) -> Result<EnvVar> {
}

fn parse_assignment_value(pair: Pair<Rule>) -> Result<Word> {
let mut parts = Vec::new();
for part in pair.into_inner() {
match part.as_rule() {
Rule::ASSIGNMENT_TILDE_PREFIX => {
let tilde_prefix = parse_tilde_prefix(part).context("Failed to parse tilde prefix")?;
parts.push(tilde_prefix);
}
Rule::UNQUOTED_PENDING_WORD => {
let word_parts = parse_word(part)?;
parts.extend(word_parts.into_parts());
}
_ => {
return Err(anyhow::anyhow!(
"Unexpected rule in assignment value: {:?}",
part.as_rule()
))
}
}
let mut parts = Vec::new();

for part in pair.into_inner() {
match part.as_rule() {
Rule::ASSIGNMENT_TILDE_PREFIX => {
let tilde_prefix =
parse_tilde_prefix(part).context("Failed to parse tilde prefix")?;
parts.push(tilde_prefix);
}
Rule::UNQUOTED_PENDING_WORD => {
let word_parts = parse_word(part)?;
parts.extend(word_parts.into_parts());
}
_ => {
return Err(anyhow::anyhow!(
"Unexpected rule in assignment value: {:?}",
part.as_rule()
))
}
}
}

Ok(Word::new(parts))
Ok(Word::new(parts))
}

fn parse_io_redirect(pair: Pair<Rule>) -> Result<Redirect> {
Expand Down
7 changes: 5 additions & 2 deletions crates/deno_task_shell/src/shell/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,13 @@ fn evaluate_word_parts(

current_text.push(TextPart::Quoted(text));
continue;
},
}
WordPart::Tilde(tilde_prefix) => {
if tilde_prefix.only_tilde() {
let home_str = dirs::home_dir().context("Failed to get home directory")?.display().to_string();
let home_str = dirs::home_dir()
.context("Failed to get home directory")?
.display()
.to_string();
current_text.push(TextPart::Text(home_str));
} else {
todo!("tilde expansion with user name is not supported");
Expand Down

0 comments on commit 6fc25ab

Please sign in to comment.