Skip to content

Commit

Permalink
refactor: avoid subshell
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Sep 28, 2023
1 parent 1e938fe commit e419556
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function(dir = '.husky'): void {
fs.copyFileSync(new URL('../husky.sh', import.meta.url), p.join(h, 'husky.sh'))

// Prepare hooks
const data = `#!/bin/sh\n. "$(dirname "$0")/husky.sh"`
const data = `#!/usr/bin/env sh\n. "\${0%/*}/husky.sh"`
for (const hook of hooks) {
fs.writeFileSync(p.join(h, hook), data, { mode: 0o755 })
}
Expand Down
9 changes: 9 additions & 0 deletions test/7_time.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
. "$(dirname -- "$0")/functions.sh"
setup
install

npx --no-install husky

git add package.json
echo "echo pre-commit" >.husky/pre-commit
time git commit -m foo
1 change: 1 addition & 0 deletions test/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ sh test/3_from-sub-dir.sh
sh test/4_not-git-dir.sh
sh test/5_git_command_not_found.sh
sh test/6_command_not_found.sh
sh test/7_time.sh

0 comments on commit e419556

Please sign in to comment.