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
feat: Add elixir section #190
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4e68fbd
Add in support for elixir
0e10a02
Add @bradcypert as a contributor
cf0ef46
add in tests
cc3411f
Update functions/__sf_section_elixir.fish
matchai 78404fd
Update functions/__sf_section_elixir.fish
matchai 1e87428
fix tests
bradcypert 15db2b7
update test to help travis-ci along
bradcypert 805fee7
Merge branch 'master' into add_elixir
bradcypert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend stubbing out the value of |
||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably the source of the test failures, because you’ve mocked
elixir -v
, but not set a mock value for$ELIXIR_VERSION
or a mock forexenv version-name
. I don’t know the specifics for Travis, but a different CI provider I use has a default version of Elixir installed usingkiex
.