Run tests task for Elixir in Visual Studio Code
In order to learn Linux I'm biting off more than I can chew by trying to learn Elixir at the same time. From the available code editors for Linux I'm using Visual Studio Code.
Visual Studio Code has the ability to configure custom tasks.
To get to the custom task configuration you can use the command palette with Ctrl + Shift + P
and type Tasks: Configure Task Runner
. This will open "tasks.json". Replace the contents with:
{
"version": "0.1.0",
"command": "bash",
"isShellCommand": true,
"showOutput": "always",
"args": [
"-c"
],
"tasks": [
{
"taskName": "Elixir-Test",
"suppressTaskName": true,
"isTestCommand": true,
"args": ["mix test"]
}
]
}
And save the file. Now if you use Ctrl + Shift + T
mix will run your tests for the project (assuming you have the mix.exs
level folder open) and print the output to the console.
This command could probably be improved by checking that it's executing in the correct folder first but I'm nowhere near confident enough with Bash to write it yet.
Further notes from adventures in Elixir
Function capturing (Capture operator)
This concept took me a little while to get to grips with because I couldn't think of an equivalent from C#.
A typical anonymous function in Elixir might take this form:
square = fn x -> x * x end
You would then call it with the dot "." between the function name and the argument like this: