Skip to content

Commit

Permalink
fix(shell): double quote params (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli authored and typicode committed Jan 27, 2021
1 parent 0a3ad97 commit b032f55
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
6 changes: 4 additions & 2 deletions .husky/commit-msg
@@ -1,4 +1,6 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

npx --no-install commitlint --edit $1
# shellcheck source=./_/husky.sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
4 changes: 3 additions & 1 deletion .husky/pre-commit
@@ -1,4 +1,6 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

# shellcheck source=./_/husky.sh
. "$(dirname "$0")/_/husky.sh"

npm test
2 changes: 1 addition & 1 deletion scripts/pre-commit
Expand Up @@ -4,7 +4,7 @@ echo "husky: installing Git hooks"

mkdir -p "$husky_dir/_"
echo "_" > "$husky_dir/.gitignore"
cp "$(dirname $0)/husky.sh" "$husky_dir/_"
cp "$(dirname "$0")/husky.sh" "$husky_dir/_"
git config core.hooksPath "$husky_dir"

echo "husky: ok"
Expand Down
2 changes: 1 addition & 1 deletion src/commands/add.ts
Expand Up @@ -15,7 +15,7 @@ function createHookFile(file: string, cmd: string) {
throw new Error(`${file} already exists`)
}

const data = ['#!/bin/sh', '. "$(dirname $0)/_/husky.sh"', '', cmd].join('\n')
const data = ['#!/bin/sh', '. "$(dirname "$0")/_/husky.sh"', '', cmd].join('\n')

fs.writeFileSync(file, data, 'utf-8')
// Show "./file" instead of just "file"
Expand Down
7 changes: 5 additions & 2 deletions test/config-dir.sh
@@ -1,6 +1,9 @@
. $(dirname $0)/_functions.sh
# shellcheck shell=bash

# Example:
# shellcheck source=./_functions.sh
. "$(dirname "$0")/_functions.sh"

# Example:
# .config/husky
title "config directory"
tempDir="/tmp/husky-config-dir-test"
Expand Down
6 changes: 4 additions & 2 deletions test/default.sh
@@ -1,4 +1,7 @@
. $(dirname $0)/_functions.sh
# shellcheck shell=bash

# shellcheck source=./_functions.sh
. "$(dirname "$0")/_functions.sh"

title "default"
tempDir="/tmp/husky-default-test"
Expand All @@ -23,4 +26,3 @@ git commit -m "should fail" || echo -e "\e[0;32mOK\e[m"
# Uninstall
npx --no-install husky uninstall
git config core.hooksPath || echo -e "\e[0;32mOK\e[m"

2 changes: 1 addition & 1 deletion test/sub-dir.sh
@@ -1,4 +1,4 @@
. $(dirname $0)/_functions.sh
. $(dirname "$0")/_functions.sh

# Example:
# .git
Expand Down

0 comments on commit b032f55

Please sign in to comment.