Skip to content

Commit dee6c11

Browse files
committed
Make directories in target, not source
1 parent 064a83b commit dee6c11

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

Dfm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ func (dfm *Dfm) LinkAll(errorHandler ErrorHandler) error {
344344
}
345345
relativePath := d[len(dfm.Config.targetPath)+1:]
346346
repoPath := s[:len(s)-len(relativePath)-1]
347-
if err := MakeDirAll(dfm.fs, path.Dir(relativePath), dfm.Config.targetPath, repoPath); err != nil {
347+
if err := MakeDirAll(dfm.fs, path.Dir(relativePath), repoPath, dfm.Config.targetPath); err != nil {
348348
return err
349349
}
350350
return LinkFile(dfm.fs, s, d)
@@ -360,7 +360,7 @@ func (dfm *Dfm) CopyAll(errorHandler ErrorHandler) error {
360360
}
361361
relativePath := d[len(dfm.Config.targetPath)+1:]
362362
repoPath := s[:len(s)-len(relativePath)-1]
363-
if err := MakeDirAll(dfm.fs, path.Dir(relativePath), dfm.Config.targetPath, repoPath); err != nil {
363+
if err := MakeDirAll(dfm.fs, path.Dir(relativePath), repoPath, dfm.Config.targetPath); err != nil {
364364
return err
365365
}
366366
return CopyFile(dfm.fs, s, d)

test/snapshot.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ skipping ./test_home/.bashrc: already up to date
1515

1616
# Adding a new config file
1717
$ dfm link
18-
files/.zshrc -> ./test_home/.zshrc
18+
files/.ssh/config -> ./test_home/.ssh/config
1919

2020
# Removing a config file
2121
$ dfm link
22-
removed .zshrc
22+
removed .ssh/config
2323

2424
# Importing with add
2525
$ dfm add test_home/.config

test/test.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ banner "Everything is up to date"
3838
dfm link -v
3939

4040
banner "Adding a new config file"
41-
echo 'config file' > dfmdir/files/.zshrc
41+
mkdir -p dfmdir/files/.ssh
42+
echo 'config file' > dfmdir/files/.ssh/config
4243
dfm link
4344
[ -L test_home/.bashrc ] || fail '.bashrc was removed'
44-
[ -L test_home/.zshrc ] || fail '.zshrc was not created'
45+
[ -L test_home/.ssh/config ] || fail '.ssh/config was not created'
4546

4647
banner "Removing a config file"
47-
rm dfmdir/files/.zshrc
48+
rm -rf dfmdir/files/.ssh
4849
dfm link
49-
[ ! -e test_home/.zshrc ] || fail '.zshrc was not removed'
50+
[ ! -e test_home/.ssh/config ] || fail '.ssh/config was not removed'
5051

5152
banner "Importing with add"
5253
mkdir -p test_home/.config/fish

0 commit comments

Comments
 (0)