This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fd54ea
commit 9cb48ea
Showing
8 changed files
with
216 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# | ||
# Elixir | ||
# | ||
# A dynamic, reflective, object-oriented, general-purpose programming language. | ||
# Link: https://www.elixir-lang.org/ | ||
|
||
function __sf_section_elixir -d "Show current version of Elixir" | ||
# ------------------------------------------------------------------------------ | ||
# Configuration | ||
# ------------------------------------------------------------------------------ | ||
|
||
__sf_util_set_default SPACEFISH_ELIXIR_SHOW true | ||
__sf_util_set_default SPACEFISH_ELIXIR_PREFIX $SPACEFISH_PROMPT_DEFAULT_PREFIX | ||
__sf_util_set_default SPACEFISH_ELIXIR_SUFFIX $SPACEFISH_PROMPT_DEFAULT_SUFFIX | ||
__sf_util_set_default SPACEFISH_ELIXIR_SYMBOL "💧 " | ||
__sf_util_set_default SPACEFISH_ELIXIR_DEFAULT_VERSION $SPACEFISH_ELIXIR_DEFAULT_VERSION | ||
__sf_util_set_default SPACEFISH_ELIXIR_COLOR magenta | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Section | ||
# ------------------------------------------------------------------------------ | ||
|
||
# Check if that user wants to show elixir version | ||
[ $SPACEFISH_ELIXIR_SHOW = false ]; and return | ||
|
||
# Show versions only for Elixir-specific folders | ||
if not test -f mix.exs \ | ||
-o (count *.ex) -gt 0 \ | ||
-o (count *.exs) -gt 0 | ||
return | ||
end | ||
|
||
set -l elixir_version | ||
|
||
if type -q kiex | ||
set elixir_version $ELIXIR_VERSION | ||
else if type -q exenv | ||
set elixir_version (exenv version-name) | ||
else if type -q elixir | ||
set elixir_version (elixir -v 2>/dev/null | string match -r "Elixir.*" | string split " ")[2] | ||
else | ||
return | ||
end | ||
|
||
[ -z "$elixir_version" -o "$elixir_version" = "system" ]; and return | ||
|
||
# Add 'v' before elixir version that starts with a number | ||
if test -n (echo (string match -r "^[0-9].+\$" "$elixir_version")) | ||
set elixir_version "v$elixir_version" | ||
end | ||
|
||
__sf_lib_section \ | ||
$SPACEFISH_ELIXIR_COLOR \ | ||
$SPACEFISH_ELIXIR_PREFIX \ | ||
"$SPACEFISH_ELIXIR_SYMBOL""$elixir_version" \ | ||
$SPACEFISH_ELIXIR_SUFFIX | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
source $DIRNAME/spacefish_test_setup.fish | ||
|
||
function setup | ||
spacefish_test_setup | ||
mock elixir -v 0 "echo \"Erlang/OTP 21 [erts-10.3.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace] | ||
Elixir 1.8.1 (compiled with Erlang/OTP 21)\"" | ||
set -x ELIXIR_VERSION 1.8.1 | ||
mkdir -p /tmp/tmp-spacefish | ||
cd /tmp/tmp-spacefish | ||
end | ||
|
||
function teardown | ||
rm -rf /tmp/tmp-spacefish | ||
end | ||
|
||
test "Prints section when mix.exs is present" | ||
( | ||
touch /tmp/tmp-spacefish/mix.exs | ||
|
||
set_color --bold | ||
echo -n "via " | ||
set_color normal | ||
set_color --bold magenta | ||
echo -n "💧 v1.8.1" | ||
set_color normal | ||
set_color --bold | ||
echo -n " " | ||
set_color normal | ||
) = (__sf_section_elixir) | ||
end | ||
|
||
test "Prints section when a *.ex file is present" | ||
( | ||
touch /tmp/tmp-spacefish/testfile.ex | ||
|
||
set_color --bold | ||
echo -n "via " | ||
set_color normal | ||
set_color --bold magenta | ||
echo -n "💧 v1.8.1" | ||
set_color normal | ||
set_color --bold | ||
echo -n " " | ||
set_color normal | ||
) = (__sf_section_elixir) | ||
end | ||
|
||
test "Doesn't print the section when mix.exs and *.ex aren't present" | ||
() = (__sf_section_elixir) | ||
end | ||
|
||
test "Changing SPACEFISH_ELIXIR_SYMBOL changes the displayed character" | ||
( | ||
touch /tmp/tmp-spacefish/mix.exs | ||
set SPACEFISH_ELIXIR_SYMBOL "· " | ||
|
||
set_color --bold | ||
echo -n "via " | ||
set_color normal | ||
set_color --bold magenta | ||
echo -n "· v1.8.1" | ||
set_color normal | ||
set_color --bold | ||
echo -n " " | ||
set_color normal | ||
) = (__sf_section_elixir) | ||
end | ||
|
||
test "Changing SPACEFISH_ELIXIR_PREFIX changes the character prefix" | ||
( | ||
touch /tmp/tmp-spacefish/mix.exs | ||
set sf_exit_code 0 | ||
set SPACEFISH_ELIXIR_PREFIX · | ||
|
||
set_color --bold | ||
echo -n "·" | ||
set_color normal | ||
set_color --bold magenta | ||
echo -n "💧 v1.8.1" | ||
set_color normal | ||
set_color --bold | ||
echo -n " " | ||
set_color normal | ||
) = (__sf_section_elixir) | ||
end | ||
|
||
test "Changing SPACEFISH_ELIXIR_SUFFIX changes the character suffix" | ||
( | ||
touch /tmp/tmp-spacefish/mix.exs | ||
set sf_exit_code 0 | ||
set SPACEFISH_ELIXIR_SUFFIX · | ||
|
||
set_color --bold | ||
echo -n "via " | ||
set_color normal | ||
set_color --bold magenta | ||
echo -n "💧 v1.8.1" | ||
set_color normal | ||
set_color --bold | ||
echo -n "·" | ||
set_color normal | ||
) = (__sf_section_elixir) | ||
end | ||
|
||
test "doesn't display the section when SPACEFISH_ELIXIR_SHOW is set to \"false\"" | ||
( | ||
touch /tmp/tmp-spacefish/mix.exs | ||
set SPACEFISH_ELIXIR_SHOW false | ||
) = (__sf_section_elixir) | ||
end |