Skip to content

Commit b6b40e4

Browse files
author
Philip Sampaio
committed
Some fixes and suggestions from the code review
1 parent 6603ff7 commit b6b40e4

File tree

4 files changed

+12
-68
lines changed

4 files changed

+12
-68
lines changed

bin/elixir.ps1

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env pwsh
22

3+
$ELIXIR_VERSION = "1.17.0-dev"
4+
35
$MinPowerShellVersion = [version]"7.2.0"
46

57
if ($MinPowerShellVersion.CompareTo([version]$PSVersionTable.PSVersion) -eq 1) {
68
Write-Error "This script requires PowerShell version 7.2 or above. Running on $($PSVersionTable.PSVersion)"
79
}
810

9-
$ELIXIR_VERSION = "1.17.0-dev"
1011
$ScriptPath = Split-Path -Parent $PSCommandPath
1112
$ErlExec = "erl"
1213

@@ -20,7 +21,7 @@ Usage: $ScriptName [options] [.exs file] [data]
2021
-e "COMMAND" Evaluates the given command (*)
2122
-h, --help Prints this message (standalone)
2223
-r "FILE" Requires the given files/patterns (*)
23-
-S SCRIPT Finds and executes the given script in \$PATH
24+
-S SCRIPT Finds and executes the given script in `$PATH
2425
-pr "FILE" Requires the given files/patterns in parallel (*)
2526
-pa "PATH" Prepends the given path to Erlang code path (*)
2627
-pz "PATH" Appends the given path to Erlang code path (*)
@@ -32,10 +33,9 @@ Usage: $ScriptName [options] [.exs file] [data]
3233
--logger-sasl-reports BOOL Enables or disables SASL reporting
3334
--no-halt Does not halt the Erlang VM after execution
3435
--short-version Prints Elixir version (standalone)
35-
--werl Uses Erlang's Windows shell GUI (Windows only)
3636
3737
Options given after the .exs file or -- are passed down to the executed code.
38-
Options can be passed to the Erlang runtime using \$ELIXIR_ERL_OPTIONS or --erl.
38+
Options can be passed to the Erlang runtime using `$ELIXIR_ERL_OPTIONS or --erl.
3939
4040
## Distribution options
4141
@@ -54,7 +54,7 @@ The following options are related to node distribution.
5454
The following options are generally used under releases.
5555
5656
--boot "FILE" Uses the given FILE.boot to start the system
57-
--boot-var VAR "VALUE" Makes \$VAR available as VALUE to FILE.boot (*)
57+
--boot-var VAR "VALUE" Makes `$VAR available as VALUE to FILE.boot (*)
5858
--erl-config "FILE" Loads configuration in FILE.config written in Erlang (*)
5959
--pipe-to "PIPEDIR" "LOGDIR" Starts the Erlang VM as a named PIPEDIR and LOGDIR
6060
--vm-args "FILE" Passes the contents in file as arguments to the VM
@@ -87,7 +87,7 @@ function NormalizeArg {
8787
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
8888
[string[]] $Items
8989
)
90-
[string]::Join(",", $Items)
90+
$Items -join ","
9191
}
9292

9393
function QuotedString {
@@ -197,7 +197,7 @@ for ($i = 0; $i -lt $Args.Count; $i++) {
197197
"--logger-sasl-reports" {
198198
$private:TempVal = $Args[$i + 1]
199199
if ($TempVal -in @("true", "false")) {
200-
$ErlangParams.AddRange([string[]]@("-logger", "handle_sasl", $Args[++$i]))
200+
$ErlangParams.AddRange([string[]]@("-logger", "handle_sasl_reports", $Args[++$i]))
201201
}
202202
break
203203
}
@@ -207,13 +207,6 @@ for ($i = 0; $i -lt $Args.Count; $i++) {
207207
break
208208
}
209209

210-
"--werl" {
211-
if ($IsWindows) {
212-
$ErlExec = "werl"
213-
}
214-
break
215-
}
216-
217210
"+iex" {
218211
$ElixirParams.Add("+iex")
219212
$UseIex = $true
@@ -301,15 +294,6 @@ for ($i = 0; $i -lt $Args.Count; $i++) {
301294
}
302295
}
303296

304-
# Support for ANSI is only disable if TERM or NO_COLOR env vars are set.
305-
# This will change the $PSStyle.OutputRendering property.
306-
if ($PSStyle.OutputRendering -ne "PlainText") {
307-
# TODO: find a way to detect if the term is interactive on Windows.
308-
if ($IsWindows -or (test -t 1 -a -t 2)) {
309-
$BeforeExtras.InsertRange(0, [string[]]@("-elixir", "ansi_enabled", "true"))
310-
}
311-
}
312-
313297
if ($null -eq $UseIEx) {
314298
$BeforeExtras.InsertRange(0, [string[]]@("-s", "elixir", "start_cli"))
315299
}
@@ -347,7 +331,7 @@ if ($ERTS_BIN) {
347331
}
348332

349333
if ($null -eq $RunErlPipe) {
350-
$ParamsPart = [string]::Join(" ", $AllParams)
334+
$ParamsPart = $AllParams -join " "
351335
}
352336
else {
353337
$private:OrigBinPath = $BinPath

bin/elixirc.ps1

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,4 @@ Usage: $ScriptName [elixir switches] [compiler switches] [.ex files]
2727
$ScriptPath = Split-Path -Parent $PSCommandPath
2828
$Command = Join-Path -Path $ScriptPath -ChildPath "elixir.ps1"
2929

30-
$NewArgs = @()
31-
$NewArgs += "+elixirc"
32-
33-
for ($i = 0; $i -lt $Args.Count; $i++) {
34-
$Arg = $Args[$i]
35-
36-
if ($Arg -is [string]) {
37-
$NewArgs += $Arg
38-
}
39-
else {
40-
$NewArgs += [string]::Join(",", $Arg)
41-
}
42-
}
43-
44-
& $Command $NewArgs
30+
Invoke-Expression "$Command +elixirc $($Args -join " ")"

bin/iex.ps1

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,4 @@ It accepts all other options listed by "elixir --help".
2222
$ScriptPath = Split-Path -Parent $PSCommandPath
2323
$Command = Join-Path -Path $ScriptPath -ChildPath "elixir.ps1"
2424

25-
$NewArgs = @("--no-halt", "--erl `"-user elixir`"", "+iex")
26-
27-
for ($i = 0; $i -lt $Args.Count; $i++) {
28-
$Arg = $Args[$i]
29-
30-
if ($Arg -is [string]) {
31-
$NewArgs += $Arg
32-
}
33-
else {
34-
$NewArgs += [string]::Join(",", $Arg)
35-
}
36-
}
37-
38-
& $Command $NewArgs
25+
Invoke-Expression "$Command --no-halt --erl `"-user elixir`" +iex $($Args -join " ")"

bin/mix.ps1

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22

33
$ScriptPath = Split-Path -Parent $PSCommandPath
44
$Command = Join-Path -Path $ScriptPath -ChildPath "elixir.ps1"
5-
$MixCommand = Join-Path -Path $ScriptPath -ChildPath "mix"
5+
$MixFile = Join-Path -Path $ScriptPath -ChildPath "mix"
66

7-
$NewArgs = @($MixCommand)
8-
9-
for ($i = 0; $i -lt $Args.Count; $i++) {
10-
$Arg = $Args[$i]
11-
12-
if ($Arg -is [string]) {
13-
$NewArgs += $Arg
14-
}
15-
else {
16-
$NewArgs += [string]::Join(",", $Arg)
17-
}
18-
}
19-
20-
& $Command $NewArgs
7+
Invoke-Expression "$Command $MixFile $($Args -join " ")"

0 commit comments

Comments
 (0)