From dee6c110283851bf1ffe34743bb8d63f7ca9446d Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Tue, 29 Oct 2019 18:01:39 +0400 Subject: [PATCH] Make directories in target, not source --- Dfm.go | 4 ++-- test/snapshot.txt | 4 ++-- test/test.sh | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Dfm.go b/Dfm.go index 2731326..9d2839e 100644 --- a/Dfm.go +++ b/Dfm.go @@ -344,7 +344,7 @@ func (dfm *Dfm) LinkAll(errorHandler ErrorHandler) error { } relativePath := d[len(dfm.Config.targetPath)+1:] repoPath := s[:len(s)-len(relativePath)-1] - if err := MakeDirAll(dfm.fs, path.Dir(relativePath), dfm.Config.targetPath, repoPath); err != nil { + if err := MakeDirAll(dfm.fs, path.Dir(relativePath), repoPath, dfm.Config.targetPath); err != nil { return err } return LinkFile(dfm.fs, s, d) @@ -360,7 +360,7 @@ func (dfm *Dfm) CopyAll(errorHandler ErrorHandler) error { } relativePath := d[len(dfm.Config.targetPath)+1:] repoPath := s[:len(s)-len(relativePath)-1] - if err := MakeDirAll(dfm.fs, path.Dir(relativePath), dfm.Config.targetPath, repoPath); err != nil { + if err := MakeDirAll(dfm.fs, path.Dir(relativePath), repoPath, dfm.Config.targetPath); err != nil { return err } return CopyFile(dfm.fs, s, d) diff --git a/test/snapshot.txt b/test/snapshot.txt index bcb1b7c..8405c09 100644 --- a/test/snapshot.txt +++ b/test/snapshot.txt @@ -15,11 +15,11 @@ skipping ./test_home/.bashrc: already up to date # Adding a new config file $ dfm link -files/.zshrc -> ./test_home/.zshrc +files/.ssh/config -> ./test_home/.ssh/config # Removing a config file $ dfm link -removed .zshrc +removed .ssh/config # Importing with add $ dfm add test_home/.config diff --git a/test/test.sh b/test/test.sh index c460a7c..9db2b8a 100755 --- a/test/test.sh +++ b/test/test.sh @@ -38,15 +38,16 @@ banner "Everything is up to date" dfm link -v banner "Adding a new config file" -echo 'config file' > dfmdir/files/.zshrc +mkdir -p dfmdir/files/.ssh +echo 'config file' > dfmdir/files/.ssh/config dfm link [ -L test_home/.bashrc ] || fail '.bashrc was removed' -[ -L test_home/.zshrc ] || fail '.zshrc was not created' +[ -L test_home/.ssh/config ] || fail '.ssh/config was not created' banner "Removing a config file" -rm dfmdir/files/.zshrc +rm -rf dfmdir/files/.ssh dfm link -[ ! -e test_home/.zshrc ] || fail '.zshrc was not removed' +[ ! -e test_home/.ssh/config ] || fail '.ssh/config was not removed' banner "Importing with add" mkdir -p test_home/.config/fish