Skip to content

Commit bd08996

Browse files
author
Amit Gold
committed
Fix bug where tilde wasn't expanded to homedir
1 parent 7dbc8b3 commit bd08996

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ structopt = "0.3.*"
1616
clap = "2.33.*"
1717
env_logger = "0.7.*"
1818
log = "0.4.*"
19+
shellexpand = "1.1.*"

src/deploy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use args;
44

55
use toml::value::Table;
66

7-
use std::fs::{self, canonicalize};
7+
use std::fs;
88
use std::io::{Read, Write, Seek};
99
use std::path::Path;
1010
use std::process;
1111

12-
use filesystem::relativize;
12+
use filesystem::{canonicalize, relativize};
1313

1414
pub fn deploy(cache_directory: &Path, cache: bool, opt: args::GlobalOptions) {
1515
// Configuration

src/filesystem.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
use shellexpand;
2+
13
use std::path::{Path, PathBuf};
4+
use std::{io, fs};
5+
6+
pub fn canonicalize<P: AsRef<Path>>(path: P) -> Result<PathBuf, io::Error> {
7+
fs::canonicalize(shellexpand::tilde(&path.as_ref().to_string_lossy()).into_owned())
8+
}
29

310
pub fn relativize(path: &Path) -> PathBuf {
411
if path.is_relative() {

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ extern crate structopt;
55
extern crate env_logger;
66
#[macro_use]
77
extern crate log;
8+
extern crate shellexpand;
89

910
mod args;
1011
mod config;

0 commit comments

Comments
 (0)