Skip to content

Commit

Permalink
feat: support empty cd (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranavchiku authored Sep 6, 2024
1 parent 97feda4 commit f484c18
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/deno_task_shell/src/shell/commands/cd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ impl ShellCommand for CdCommand {
}

fn execute_cd(cwd: &Path, args: Vec<String>) -> Result<PathBuf> {
let path = parse_args(args)?;
// create a new vector to avoid modifying the original
let mut args = args;
if args.is_empty() {
// append `~` to args
args.push("~".to_string());
}
let path = parse_args(args.clone())?;
let new_dir = if path == "~" {
dirs::home_dir()
.ok_or_else(|| anyhow::anyhow!("Home directory not found"))?
Expand Down

0 comments on commit f484c18

Please sign in to comment.