2021-05-31 20:42:45 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-06-05 13:22:24 -04:00
|
|
|
set -eu
|
2021-05-31 20:42:45 -04:00
|
|
|
|
2021-06-05 13:22:24 -04:00
|
|
|
log() {
|
|
|
|
echo -e "$1" >&2
|
|
|
|
}
|
2021-05-31 20:42:45 -04:00
|
|
|
|
2021-06-05 13:22:24 -04:00
|
|
|
CMD_NAME="typos"
|
|
|
|
TARGET=${INPUT_FILES:-"."}
|
2021-05-31 20:42:45 -04:00
|
|
|
|
2021-06-05 13:22:24 -04:00
|
|
|
if [[ -z $(ls ${TARGET} 2>/dev/null) ]]; then
|
|
|
|
log "ERROR: Input files (${TARGET}) not found"
|
|
|
|
exit 1
|
2021-05-31 20:42:45 -04:00
|
|
|
fi
|
2021-06-05 13:22:24 -04:00
|
|
|
if [[ -z $(which ${CMD_NAME} 2>/dev/null) ]]; then
|
|
|
|
log "ERROR: 'typos' not found"
|
|
|
|
exit 1
|
2021-05-31 20:42:45 -04:00
|
|
|
fi
|
|
|
|
|
2021-06-05 13:22:24 -04:00
|
|
|
COMMAND="${CMD_NAME} ${TARGET}"
|
2021-05-31 20:42:45 -04:00
|
|
|
|
2021-06-05 13:22:24 -04:00
|
|
|
# Ignore implicit configuration files
|
|
|
|
if [ "${INPUT_ISOLATED:-false}" == "true" ]; then
|
|
|
|
COMMAND+=" --isolated"
|
2021-05-31 20:42:45 -04:00
|
|
|
fi
|
|
|
|
|
2021-06-05 13:22:24 -04:00
|
|
|
# Use a custom configuration file
|
|
|
|
if [[ -n "${INPUT_CONFIG:-}" ]]; then
|
|
|
|
COMMAND+=" --config ${INPUT_CONFIG}"
|
2021-05-31 20:42:45 -04:00
|
|
|
fi
|
|
|
|
|
2021-06-05 13:22:24 -04:00
|
|
|
log "$ ${COMMAND}"
|
2021-05-31 20:42:45 -04:00
|
|
|
${COMMAND}
|