Skip to content

Commit f99f6e9

Browse files
committedJan 22, 2021
detect container runtime
1 parent 98b687a commit f99f6e9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

‎pre-commit.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,16 @@ if [ ! -d $pcommit_cache ]; then
3333
mkdir -p $pcommit_cache;
3434
fi
3535

36+
### Helper functions
37+
function has() {
38+
curl -sL https://git.io/_has | bash -s $1 > /dev/null
39+
return $?
40+
}
41+
3642
# Execute container image
37-
podman run --name ${container_name} -ti \
43+
has "podman" && command="podman" || has "docker" && command="docker"
44+
45+
$command run --name ${container_name} -ti \
3846
-v ${book}:${container_book}:z \
3947
-v ${ssh_cfg_cpy}:${container_ssh_cfg}:z,ro \
4048
-v ${pcommit_cache}:${container_pcommit_cache}:z \
@@ -43,6 +51,6 @@ exitcode=$?
4351

4452
# Cleanup
4553
rm -rf ${ssh_cfg_cpy}
46-
podman rm -f ${container_name} > /dev/null
54+
$command rm -f ${container_name} > /dev/null
4755

4856
exit $exitcode

0 commit comments

Comments
 (0)
Please sign in to comment.