diff --git a/hooks/command b/hooks/command index d0fb345..381ac95 100755 --- a/hooks/command +++ b/hooks/command @@ -35,7 +35,7 @@ if [[ -z ${files:-} ]] ; then fi echo "+++ Running shellcheck on ${#files[@]} files" -if docker run --rm -v "$PWD:/mnt" koalaman/shellcheck "${files[@]}" ; then +if docker run --rm -v "$PWD:/mnt" --workdir "/mnt" koalaman/shellcheck "${files[@]}" ; then echo "Files are ok ✅" else exit 1 diff --git a/tests/run.bats b/tests/run.bats index 8907141..ce94da7 100644 --- a/tests/run.bats +++ b/tests/run.bats @@ -8,7 +8,7 @@ load '/usr/local/lib/bats/load.bash' export BUILDKITE_PLUGIN_SHELLCHECK_FILES_0="tests/testdata/test.sh" stub docker \ - "run --rm -v $PWD:/mnt koalaman/shellcheck tests/testdata/test.sh : echo testing test.sh" + "run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck tests/testdata/test.sh : echo testing test.sh" run "$PWD/hooks/command" @@ -24,7 +24,7 @@ load '/usr/local/lib/bats/load.bash' export BUILDKITE_PLUGIN_SHELLCHECK_FILES_2="missing" stub docker \ - "run --rm -v $PWD:/mnt koalaman/shellcheck tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell\ with\ space.sh' : echo testing test.sh" + "run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell\ with\ space.sh' : echo testing test.sh" run "$PWD/hooks/command" @@ -38,7 +38,7 @@ load '/usr/local/lib/bats/load.bash' export BUILDKITE_PLUGIN_SHELLCHECK_FILES_0="tests/testdata/subdir/llamas.sh" stub docker \ - "run --rm -v $PWD:/mnt koalaman/shellcheck tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell\ with\ space.sh' : echo shellcheck failed; exit 1" + "run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell\ with\ space.sh' : echo shellcheck failed; exit 1" run "$PWD/hooks/command"