Skip to content

Commit

Permalink
Fix bug where tilde wasn't expanded to homedir
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Gold committed Jul 29, 2020
1 parent 7dbc8b3 commit bd08996
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ structopt = "0.3.*"
clap = "2.33.*"
env_logger = "0.7.*"
log = "0.4.*"
shellexpand = "1.1.*"
4 changes: 2 additions & 2 deletions src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use args;

use toml::value::Table;

use std::fs::{self, canonicalize};
use std::fs;
use std::io::{Read, Write, Seek};
use std::path::Path;
use std::process;

use filesystem::relativize;
use filesystem::{canonicalize, relativize};

pub fn deploy(cache_directory: &Path, cache: bool, opt: args::GlobalOptions) {
// Configuration
Expand Down
7 changes: 7 additions & 0 deletions src/filesystem.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
use shellexpand;

use std::path::{Path, PathBuf};
use std::{io, fs};

pub fn canonicalize<P: AsRef<Path>>(path: P) -> Result<PathBuf, io::Error> {
fs::canonicalize(shellexpand::tilde(&path.as_ref().to_string_lossy()).into_owned())
}

pub fn relativize(path: &Path) -> PathBuf {
if path.is_relative() {
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern crate structopt;
extern crate env_logger;
#[macro_use]
extern crate log;
extern crate shellexpand;

mod args;
mod config;
Expand Down

0 comments on commit bd08996

Please sign in to comment.