From 2e21805050c615f635d2055f818ee2a1763957e2 Mon Sep 17 00:00:00 2001 From: Sanchit Ram Arvind Date: Thu, 25 May 2023 08:09:40 +0530 Subject: [PATCH] +zsh-syntax-highlighting (#2000) * +zsh-syntax-highlighting * Removed $HOME You'd still have to run a command yourself post installation. * added test * missing fixture * no executable * clean up * comment out user message in build script * don't need gum --------- Co-authored-by: Jacob Heider --- .../zsh-syntax-highlighting/fixture.sh | 30 ++++++++++++++++++ .../zsh-syntax-highlighting/package.yml | 31 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 projects/github.com/zsh-users/zsh-syntax-highlighting/fixture.sh create mode 100644 projects/github.com/zsh-users/zsh-syntax-highlighting/package.yml diff --git a/projects/github.com/zsh-users/zsh-syntax-highlighting/fixture.sh b/projects/github.com/zsh-users/zsh-syntax-highlighting/fixture.sh new file mode 100644 index 00000000..c850f70a --- /dev/null +++ b/projects/github.com/zsh-users/zsh-syntax-highlighting/fixture.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Receive the directory as the first command-line argument +directory="$1" + +# Check if the directory is provided +if [ -z "$directory" ]; then + echo "Directory parameter is missing." + exit 1 +fi + +# Change to the specified directory +cd "$directory" || { echo "Failed to change to the specified directory."; exit 1; } + +# Run the test & read the lines +output=$(zsh tests/test-highlighting.zsh main) +lines=() +while IFS= read -r line; do + lines+=("$line") +done <<< "$output" + +# If line has 'not ok', with no '#TODO' --> fail & exit +for line in "${lines[@]}"; do + if [[ $line =~ ^(.*\bnot ok\b)(.*)$ && ! $line =~ "#TODO" ]]; then + echo "Fail" + exit 1 + fi +done + +echo "Pass" diff --git a/projects/github.com/zsh-users/zsh-syntax-highlighting/package.yml b/projects/github.com/zsh-users/zsh-syntax-highlighting/package.yml new file mode 100644 index 00000000..515471c7 --- /dev/null +++ b/projects/github.com/zsh-users/zsh-syntax-highlighting/package.yml @@ -0,0 +1,31 @@ +distributable: + url: https://github.com/zsh-users/zsh-syntax-highlighting/archive/refs/tags/{{version}}.tar.gz + strip-components: 1 + +versions: + github: zsh-users/zsh-syntax-highlighting/tags + +build: + dependencies: + tea.xyz/gx/cc: c99 + tea.xyz/gx/make: '*' + #charm.sh/gum: '*' + script: + - make --jobs {{ hw.concurrency }} install + # Users need to source this in their zsh configs + # - export ZSH_HIGHLIGHTING={{prefix}}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + # TODO: #2008 + # - gum format "# *Finish the install by running*" '## `echo "source '$ZSH_HIGHLIGHTING'" >> $HOME/.zshrc`' | gum format + + # Use tests provided by the highlighter for test + - | + mkdir {{prefix}}/share/zsh-syntax-highlighting/tests {{prefix}}/share/zsh-syntax-highlighting/highlighters/main/test-data + cp -r ./tests/* {{prefix}}/share/zsh-syntax-highlighting/tests + cp ./highlighters/main/test-data/alias-basic.zsh {{prefix}}/share/zsh-syntax-highlighting/highlighters/main/test-data + env: + ARGS: + - --prefix="{{prefix}}" + +test: | + chmod +x ./fixture.sh + ./fixture.sh {{prefix}}/share/zsh-syntax-highlighting