From ec8341bf650b2536120587fb520be0c2a1b833f9 Mon Sep 17 00:00:00 2001 From: pylipp Date: Mon, 6 Jan 2020 20:30:05 +0100 Subject: [PATCH] Add shellcheck app management file - See #3. --- lib/sdd/apps/user/shellcheck | 23 +++++++++++++++++++++++ test/apps/shellcheck.bats | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 lib/sdd/apps/user/shellcheck create mode 100644 test/apps/shellcheck.bats diff --git a/lib/sdd/apps/user/shellcheck b/lib/sdd/apps/user/shellcheck new file mode 100644 index 0000000..7325897 --- /dev/null +++ b/lib/sdd/apps/user/shellcheck @@ -0,0 +1,23 @@ +#! /bin/bash + +sdd_install() { + local version=$1 + local package=shellcheck-$version + local archive=$package.linux.x86_64.tar.xz + + wget -P /tmp https://shellcheck.storage.googleapis.com/$archive + cd /tmp + tar xf $archive + + mv $package/shellcheck "$SDD_INSTALL_PREFIX"/bin + + rm -rf $archive $package +} + +sdd_uninstall() { + rm -v "$SDD_INSTALL_PREFIX"/bin/shellcheck +} + +sdd_fetch_latest_version() { + _name_of_latest_github_tag koalaman shellcheck +} diff --git a/test/apps/shellcheck.bats b/test/apps/shellcheck.bats new file mode 100644 index 0000000..6324ade --- /dev/null +++ b/test/apps/shellcheck.bats @@ -0,0 +1,19 @@ +load '/usr/local/libexec/bats-support/load.bash' +load '/usr/local/libexec/bats-assert/load.bash' + +@test "shellcheck of recent version can be installed and uninstalled" { + run sdd install shellcheck + assert_success + assert_line -n 0 -p 'Latest version available: ' + assert_output -p 'Installed "shellcheck".' + + run shellcheck --version + [ $status -eq 0 ] + + run sdd uninstall shellcheck + [ $status -eq 0 ] + [ "${lines[-1]}" = 'Uninstalled "shellcheck".' ] + + run which shellcheck + [ $status -eq 1 ] +}