mirror of
https://github.com/denisidoro/navi
synced 2024-11-24 20:43:06 +00:00
Add tests (#3)
This commit is contained in:
parent
2fdb55f261
commit
2bc52976c2
11 changed files with 95 additions and 12 deletions
26
.circleci/config.yml
Normal file
26
.circleci/config.yml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# Clojure CircleCI 2.0 configuration file
|
||||||
|
#
|
||||||
|
# Check https://circleci.com/docs/2.0/language-clojure/ for more details
|
||||||
|
#
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
job_defaults: &defaults
|
||||||
|
docker:
|
||||||
|
- image: frolvlad/alpine-bash
|
||||||
|
working_directory: ~/repo
|
||||||
|
environment:
|
||||||
|
ENVIRONMENT: "test"
|
||||||
|
TERM: "dumb"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
<<: *defaults
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run: ./test/find_cheats
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
run-tests:
|
||||||
|
jobs:
|
||||||
|
- tests
|
10
Makefile
10
Makefile
|
@ -1,8 +1,8 @@
|
||||||
BIN ?= navi
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
scripts/symlink
|
scripts/install
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f $(PREFIX)/bin/$(BIN)
|
scripts/uninstall
|
||||||
|
|
||||||
|
release:
|
||||||
|
scripts/release
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# navi
|
# navi [![CircleCI](https://circleci.com/gh/denisidoro/navi.svg?style=svg)](https://circleci.com/gh/denisidoro/navi)
|
||||||
|
|
||||||
An interactive cheatsheet tool for the command-line so that you'll never say the following again:
|
An interactive cheatsheet tool for the command-line so that you'll never say the following again:
|
||||||
|
|
||||||
|
@ -53,7 +53,12 @@ Or you can launch and browser and search for instructions on Google, but that ta
|
||||||
|
|
||||||
In this case, you need to pass the directory which contains `.cheat` files as in:
|
In this case, you need to pass the directory which contains `.cheat` files as in:
|
||||||
```sh
|
```sh
|
||||||
navi --dir /folder/with/cheats
|
navi --dir "/folder/with/cheats"
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, you can set an environment variable in your `.bashrc`-like file:
|
||||||
|
```sh
|
||||||
|
export NAVI_DIR="/folder/with/cheats"
|
||||||
```
|
```
|
||||||
|
|
||||||
## .cheat syntax
|
## .cheat syntax
|
||||||
|
|
2
navi
2
navi
|
@ -22,6 +22,6 @@ source "${SCRIPT_DIR}/src/main.sh"
|
||||||
##? --print Prevent script execution [default: false]
|
##? --print Prevent script execution [default: false]
|
||||||
##? --no-interpolation Prevent argument interpolation [default: false]
|
##? --no-interpolation Prevent argument interpolation [default: false]
|
||||||
|
|
||||||
VERSION="0.5.0"
|
VERSION="0.6.0"
|
||||||
docs::eval "$@"
|
docs::eval "$@"
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
26
scripts/release
Executable file
26
scripts/release
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
|
tag="v$*"
|
||||||
|
tar="https://github.com/denisidoro/navi/archive/v${tag}.tar.gz"
|
||||||
|
formula="/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/navi.rb"
|
||||||
|
|
||||||
|
echo "Attempting to release version ${tag}..."
|
||||||
|
|
||||||
|
echo "git tag"
|
||||||
|
git tag -a "$tag" -m "$tag"
|
||||||
|
|
||||||
|
echo "git push"
|
||||||
|
git push --follow-tags
|
||||||
|
|
||||||
|
echo "rm formula"
|
||||||
|
rm "$formula" || true
|
||||||
|
|
||||||
|
echo "brew create"
|
||||||
|
brew create "$tar"
|
||||||
|
|
||||||
|
echo "output"
|
||||||
|
grep "url" "$formula" -A1
|
5
scripts/uninstall
Executable file
5
scripts/uninstall
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BIN="/usr/local/bin/navi"
|
||||||
|
rm -rf "$BIN" || true
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
cheat::find() {
|
cheat::find() {
|
||||||
find "${cheat_dir:-"${SCRIPT_DIR}/cheats"}" -iname '*.cheat'
|
find "${NAVI_DIR:-"${SCRIPT_DIR}/cheats"}" -iname '*.cheat'
|
||||||
}
|
}
|
||||||
|
|
||||||
cheat::read_many() {
|
cheat::read_many() {
|
||||||
|
|
|
@ -14,7 +14,7 @@ docs::eval() {
|
||||||
|
|
||||||
for arg in $@; do
|
for arg in $@; do
|
||||||
case $wait_for in
|
case $wait_for in
|
||||||
dir) cheat_dir="$arg"; wait_for="";;
|
dir) NAVI_DIR="$arg"; wait_for="";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case $arg in
|
case $arg in
|
||||||
|
@ -25,6 +25,4 @@ docs::eval() {
|
||||||
-d|--dir) wait_for="dir";;
|
-d|--dir) wait_for="dir";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "cheat_dir: ${cheat_dir:-}"
|
|
||||||
}
|
}
|
||||||
|
|
13
test/core.sh
Normal file
13
test/core.sh
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source <(
|
||||||
|
grep -v 'main ' "${SCRIPT_DIR}/navi" | sed -E "s|export.*|export SCRIPT_DIR=\"${SCRIPT_DIR}\"|")
|
||||||
|
|
||||||
|
test::success() {
|
||||||
|
echo "Test passed!"
|
||||||
|
}
|
||||||
|
|
||||||
|
test::fail() {
|
||||||
|
echo "Test failed..."
|
||||||
|
exit 42
|
||||||
|
}
|
10
test/find_cheats
Executable file
10
test/find_cheats
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
source "${SCRIPT_DIR}/test/core.sh"
|
||||||
|
|
||||||
|
cheat::find \
|
||||||
|
| grep -q "docker.cheat" \
|
||||||
|
&& test::success \
|
||||||
|
|| test::fail
|
Loading…
Reference in a new issue