Skip to content

Commit

Permalink
Merge pull request #13 from voitau/master
Browse files Browse the repository at this point in the history
Fix color term dependency.
  • Loading branch information
voitau authored Apr 2, 2020
2 parents d53c948 + 7893a02 commit 62c0eaf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: linting
name: lint

on:
push:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ jobs:
- name: Execute unit tests
run: |
export TERM=xterm-256color
$HOME/opt/bats/bin/bats test/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/markdown-localization/mdlm-sh)
[![linting](https://github.com/markdown-localization/mdlm-sh/workflows/linting/badge.svg)](https://github.com/markdown-localization/mdlm-sh/actions?query=workflow:linting)
[![lint](https://github.com/markdown-localization/mdlm-sh/workflows/lint/badge.svg)](https://github.com/markdown-localization/mdlm-sh/actions?query=workflow:lint)
[![unit-tests](https://github.com/voitau/mdlm-sh/workflows/unit-tests/badge.svg)](https://github.com/markdown-localization/mdlm-sh/actions?query=workflow:unit-tests)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3814/badge)](https://bestpractices.coreinfrastructure.org/projects/3814)

Expand Down
26 changes: 20 additions & 6 deletions mdlm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,23 @@ MDLM_IGNORE_END="<!-- @l10n:ignore end -->"

MDLM_ADD_LINK="https://github.com/markdown-localization/markdown-localization-spec#workflow"

normal=$'\e[0m'
green=$(tput setaf 2)
red=$(tput setaf 1)
yellow=$(tput setaf 3)
blue=$(tput setaf 6)
USE_COLORS="auto"

mdlm_setup_colors() {
if test -t 1; then
ncolors="$(tput colors)"
if [ -n "${ncolors}" ] && [ "${ncolors}" -ge 8 ]; then
USE_COLORS="always"
normal=$'\e[0m'
green=$(tput setaf 2)
red=$(tput setaf 1)
yellow=$(tput setaf 3)
blue=$(tput setaf 6)
else
USE_COLORS="never"
fi
fi
}

mdlm_echo() {
command printf %s\\n "$*" 2>/dev/null
Expand Down Expand Up @@ -268,7 +280,7 @@ mdlm_update_all_headers() {
}

mdlm_original_diff() {
diff --color -B \
diff --color="${USE_COLORS}" -B \
<(grep -v "${MDLM_HEADER}" "${2}" \
| sed -e "/${MDLM_P_CLOSE}/,/${MDLM_P_OPEN}/d" -e "/${MDLM_P_OPEN}/d" -e "/$MDLM_IGNORE_START/,/$MDLM_IGNORE_END/d") \
<(grep -v "${MDLM_HEADER}" "${1}" | sed -e "/${MDLM_IGNORE_START}/,/${MDLM_IGNORE_END}/d")
Expand Down Expand Up @@ -365,6 +377,8 @@ mdlm_help() {
}

mdlm() {
mdlm_setup_colors

if [ $# -lt 1 ]; then
mdlm help
return
Expand Down
1 change: 0 additions & 1 deletion test/test-blank.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ teardown() {
}

@test "mdlm - with no arguments" {
$mdlm
run $mdlm
[ $status -eq 0 ]
[ $(expr "$output" : "Markdown Localization Manager (Bash) [0-9][0-9.]*") -ne 0 ]
Expand Down

0 comments on commit 62c0eaf

Please sign in to comment.