Skip to content

Commit

Permalink
Make directories in target, not source
Browse files Browse the repository at this point in the history
  • Loading branch information
CGamesPlay committed Oct 29, 2019
1 parent 064a83b commit dee6c11
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Dfm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/snapshot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dee6c11

Please sign in to comment.