Skip to content

Commit

Permalink
fix(hook): creates relative paths before linking/copying (#36)
Browse files Browse the repository at this point in the history
Fixes #33
  • Loading branch information
jmgilman committed Jun 20, 2022
1 parent 1640dd9 commit 0fb7666
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
9 changes: 3 additions & 6 deletions .config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,11 @@ let
"test"
];
scopes = [
"conform"
"ghsettings"
"just"
"lefthook"
"pre-commit"
"prettier"
"engine"
"hook"
"core"
"flake"
"request"
];
};
};
Expand Down
7 changes: 7 additions & 0 deletions lib/hooks/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@
fi
}
try_make_path() {
dirname="$(dirname ''${1})"
if [[ ! -d "$dirname" ]]; then
mkdir -p "$dirname"
fi
}
PS4='+ Line $(expr $LINENO + 4): '
''
3 changes: 2 additions & 1 deletion lib/hooks/copy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ in
fi
else
# We need to create the first iteration of the file
log "${output} copy created"
try_make_path ${output}
install -m 644 ${configFile} ${output}
log "${output} copy created"
# Run extra shell hook
${extra}
Expand Down
1 change: 1 addition & 0 deletions lib/hooks/link.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ in
unlink ${output}
fi
try_make_path ${output}
ln -s ${configFile} ${output}
# Run extra shell hook
Expand Down

0 comments on commit 0fb7666

Please sign in to comment.