Skip to content

Commit 5222092

Browse files
author
Philip Sampaio
committed
Change PowerShell vars from PascalCase to camelCase
1 parent da5035d commit 5222092

File tree

4 files changed

+122
-123
lines changed

4 files changed

+122
-123
lines changed

bin/elixir.ps1

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

33
$ELIXIR_VERSION = "1.17.0-dev"
44

5-
$MinPowerShellVersion = [version]"7.2.0"
5+
$minPowerShellVersion = [version]"7.2.0"
66

7-
if ($MinPowerShellVersion.CompareTo([version]$PSVersionTable.PSVersion) -eq 1) {
7+
if ($minPowerShellVersion.CompareTo([version]$PSVersionTable.PSVersion) -eq 1) {
88
Write-Error "This script requires PowerShell version 7.2 or above. Running on $($PSVersionTable.PSVersion)"
99
}
1010

11-
$ScriptPath = Split-Path -Parent $PSCommandPath
12-
$ErlExec = "erl"
11+
$scriptPath = Split-Path -Parent $PSCommandPath
12+
$erlExec = "erl"
1313

1414
function PrintElixirHelp {
15-
$ScriptName = Split-Path -Leaf $PSCommandPath
16-
$Help = @"
17-
Usage: $ScriptName [options] [.exs file] [data]
15+
$scriptName = Split-Path -Leaf $PSCommandPath
16+
$help = @"
17+
Usage: $scriptName [options] [.exs file] [data]
1818
1919
## General options
2020
@@ -69,15 +69,15 @@ See run_erl to learn more. To reattach, run: to_erl PIPEDIR.
6969
** Standalone options can't be combined with other options.
7070
"@
7171

72-
Write-Host $Help
72+
Write-Host $help
7373
}
7474

75-
if (($Args.Count -eq 1) -and ($Args[0] -eq "--short-version")) {
75+
if (($args.Count -eq 1) -and ($args[0] -eq "--short-version")) {
7676
Write-Host "$ELIXIR_VERSION"
7777
exit
7878
}
7979

80-
if (($Args.Count -eq 0) -or (($Args.Count -eq 1) -and ($Args[0] -in @("-h", "--help")))) {
80+
if (($args.Count -eq 0) -or (($args.Count -eq 1) -and ($args[0] -in @("-h", "--help")))) {
8181
PrintElixirHelp
8282
exit 1
8383
}
@@ -109,172 +109,172 @@ function QuoteString {
109109
}
110110
}
111111

112-
$ElixirParams = New-Object Collections.Generic.List[String]
113-
$ErlangParams = New-Object Collections.Generic.List[String]
114-
$BeforeExtras = New-Object Collections.Generic.List[String]
115-
$AllOtherParams = New-Object Collections.Generic.List[String]
112+
$elixirParams = New-Object Collections.Generic.List[String]
113+
$erlangParams = New-Object Collections.Generic.List[String]
114+
$beforeExtras = New-Object Collections.Generic.List[String]
115+
$allOtherParams = New-Object Collections.Generic.List[String]
116116

117-
$RunErlPipe = $null
118-
$RunErlLog = $null
117+
$runErlPipe = $null
118+
$runErlLog = $null
119119

120-
for ($i = 0; $i -lt $Args.Count; $i++) {
121-
$private:Arg = $Args[$i]
120+
for ($i = 0; $i -lt $args.Count; $i++) {
121+
$private:arg = $args[$i]
122122

123-
switch ($Arg) {
123+
switch ($arg) {
124124
{ $_ -in @("-e", "-r", "-pr", "-pa", "-pz", "--eval", "--remsh", "--dot-iex", "--dbg") } {
125-
$private:NextArg = NormalizeArg($Args[++$i])
125+
$private:nextArg = NormalizeArg($args[++$i])
126126

127-
$ElixirParams.Add($Arg)
128-
$ElixirParams.Add($NextArg)
127+
$elixirParams.Add($arg)
128+
$elixirParams.Add($nextArg)
129129

130130
break
131131
}
132132

133133
{ $_ -in @("-v", "--version") } {
134134
# Standalone options goes only once in the Elixir params, when they are empty.
135-
if (($ElixirParams.Count -eq 0) -and ($AllOtherParams.Count -eq 0)) {
136-
$ElixirParams.Add($Arg)
135+
if (($elixirParams.Count -eq 0) -and ($allOtherParams.Count -eq 0)) {
136+
$elixirParams.Add($arg)
137137
}
138138
else {
139-
$AllOtherParams.Add($Arg)
139+
$allOtherParams.Add($arg)
140140
}
141141
break
142142
}
143143

144144
"--no-halt" {
145-
$ElixirParams.Add($Arg)
145+
$elixirParams.Add($arg)
146146
break
147147
}
148148

149149
"--cookie" {
150-
$ErlangParams.Add("-setcookie")
151-
$ErlangParams.Add($Args[++$i])
150+
$erlangParams.Add("-setcookie")
151+
$erlangParams.Add($args[++$i])
152152
break
153153
}
154154

155155
"--hidden" {
156-
$ErlangParams.Add("-hidden")
156+
$erlangParams.Add("-hidden")
157157
break
158158
}
159159

160160
"--name" {
161-
$ErlangParams.Add("-name")
162-
$ErlangParams.Add($Args[++$i])
161+
$erlangParams.Add("-name")
162+
$erlangParams.Add($args[++$i])
163163
break
164164
}
165165

166166
"--sname" {
167-
$ErlangParams.Add("-sname")
168-
$ErlangParams.Add($Args[++$i])
167+
$erlangParams.Add("-sname")
168+
$erlangParams.Add($args[++$i])
169169
break
170170
}
171171

172172
"--boot" {
173-
$ErlangParams.Add("-boot")
174-
$ErlangParams.Add($Args[++$i])
173+
$erlangParams.Add("-boot")
174+
$erlangParams.Add($args[++$i])
175175
break
176176
}
177177

178178
"--erl-config" {
179-
$ErlangParams.Add("-config")
180-
$ErlangParams.Add($Args[++$i])
179+
$erlangParams.Add("-config")
180+
$erlangParams.Add($args[++$i])
181181
break
182182
}
183183

184184
"--vm-args" {
185-
$ErlangParams.Add("-args_file")
186-
$ErlangParams.Add($Args[++$i])
185+
$erlangParams.Add("-args_file")
186+
$erlangParams.Add($args[++$i])
187187
break
188188
}
189189

190190
"--logger-otp-reports" {
191-
$private:TempVal = $Args[$i + 1]
192-
if ($TempVal -in @("true", "false")) {
193-
$ErlangParams.AddRange([string[]]@("-logger", "handle_otp_reports", $Args[++$i]))
191+
$private:tempVal = $args[$i + 1]
192+
if ($tempVal -in @("true", "false")) {
193+
$erlangParams.AddRange([string[]]@("-logger", "handle_otp_reports", $args[++$i]))
194194
}
195195
break
196196
}
197197

198198
"--logger-sasl-reports" {
199-
$private:TempVal = $Args[$i + 1]
200-
if ($TempVal -in @("true", "false")) {
201-
$ErlangParams.AddRange([string[]]@("-logger", "handle_sasl_reports", $Args[++$i]))
199+
$private:tempVal = $args[$i + 1]
200+
if ($tempVal -in @("true", "false")) {
201+
$erlangParams.AddRange([string[]]@("-logger", "handle_sasl_reports", $args[++$i]))
202202
}
203203
break
204204
}
205205

206206
"--erl" {
207-
$BeforeExtras.Add($Args[++$i])
207+
$beforeExtras.Add($args[++$i])
208208
break
209209
}
210210

211211
"+iex" {
212-
$ElixirParams.Add("+iex")
213-
$UseIex = $true
212+
$elixirParams.Add("+iex")
213+
$useIex = $true
214214

215215
break
216216
}
217217

218218
"+elixirc" {
219-
$ElixirParams.Add("+elixirc")
219+
$elixirParams.Add("+elixirc")
220220
break
221221
}
222222

223223
"--rpc-eval" {
224-
$private:Key = $Args[++$i]
225-
$private:Value = $Args[++$i]
224+
$private:key = $args[++$i]
225+
$private:value = $args[++$i]
226226

227-
if ($null -eq $Key) {
227+
if ($null -eq $key) {
228228
Write-Error "--rpc-eval: NODE must be present"
229229
exit 1
230230
}
231231

232-
if ($null -eq $Value) {
233-
Write-Error "--rpc-eval: COMMAND for the '$Key' node must be present"
232+
if ($null -eq $value) {
233+
Write-Error "--rpc-eval: COMMAND for the '$key' node must be present"
234234
exit 1
235235
}
236236

237-
$ElixirParams.Add("--rpc-eval")
238-
$ElixirParams.Add($Key)
239-
$ElixirParams.Add($Value)
237+
$elixirParams.Add("--rpc-eval")
238+
$elixirParams.Add($key)
239+
$elixirParams.Add($value)
240240
break
241241
}
242242

243243
"--boot-var" {
244-
$private:Key = $Args[++$i]
245-
$private:Value = $Args[++$i]
244+
$private:key = $args[++$i]
245+
$private:value = $args[++$i]
246246

247-
if ($null -eq $Key) {
247+
if ($null -eq $key) {
248248
Write-Error "--boot-var: VAR must be present"
249249
exit 1
250250
}
251251

252-
if ($null -eq $Value) {
253-
Write-Error "--boot-var: Value for the '$Key' var must be present"
252+
if ($null -eq $value) {
253+
Write-Error "--boot-var: Value for the '$key' var must be present"
254254
exit 1
255255
}
256256

257-
$ElixirParams.Add("-boot_var")
258-
$ElixirParams.Add($Key)
259-
$ElixirParams.Add($Value)
257+
$elixirParams.Add("-boot_var")
258+
$elixirParams.Add($key)
259+
$elixirParams.Add($value)
260260
break
261261
}
262262

263263
"--pipe-to" {
264-
$RunErlPipe = $Args[++$i]
265-
$RunErlLog = $Args[++$i]
264+
$runErlPipe = $args[++$i]
265+
$runErlLog = $args[++$i]
266266

267-
if ($null -eq $RunErlPipe) {
267+
if ($null -eq $runErlPipe) {
268268
Write-Error "--pipe-to: PIPEDIR must be present"
269269
exit 1
270270
}
271271

272-
if ($null -eq $RunErlLog) {
272+
if ($null -eq $runErlLog) {
273273
Write-Error "--pipe-to: PIPELOG must be present"
274274
exit 1
275275
}
276276

277-
if ($RunErlPipe.EndsWith("/") -or $RunErlLog.EndsWith("/")) {
277+
if ($runErlPipe.EndsWith("/") -or $runErlLog.EndsWith("/")) {
278278
Write-Error "--pipe-to: PIPEDIR and PIPELOG must not end with a slash"
279279
exit 1
280280
}
@@ -283,80 +283,79 @@ for ($i = 0; $i -lt $Args.Count; $i++) {
283283
}
284284

285285
Default {
286-
$private:Normalized = NormalizeArg $Arg
287-
$AllOtherParams.Add($Normalized)
286+
$private:normalized = NormalizeArg $arg
287+
$allOtherParams.Add($normalized)
288288
break
289289
}
290290
}
291291
}
292292

293-
if ($null -eq $UseIEx) {
294-
$BeforeExtras.InsertRange(0, [string[]]@("-s", "elixir", "start_cli"))
293+
if ($null -eq $useIEx) {
294+
$beforeExtras.InsertRange(0, [string[]]@("-s", "elixir", "start_cli"))
295295
}
296296

297-
$BeforeExtras.InsertRange(0, [string[]]@("-pa", "$(Join-Path $ScriptPath -ChildPath "../lib/elixir/ebin")"))
298-
$BeforeExtras.InsertRange(0, [string[]]@("-noshell", "-elixir_root", "$(Join-Path $ScriptPath -ChildPath "../lib")"))
297+
$beforeExtras.InsertRange(0, [string[]]@("-pa", "$(Join-Path $scriptPath -ChildPath "../lib/elixir/ebin")"))
298+
$beforeExtras.InsertRange(0, [string[]]@("-noshell", "-elixir_root", "$(Join-Path $scriptPath -ChildPath "../lib")"))
299299

300300
# One MAY change ERTS_BIN= but you MUST NOT change
301301
# ERTS_BIN=$ERTS_BIN as it is handled by Elixir releases.
302302
# TODO: change when we port the releases scripts.
303303
# $ERTS_BIN=
304-
$ERTS_BIN = "$Env:ERTS_BIN"
304+
$ERTS_BIN = "$env:ERTS_BIN"
305305

306-
$ELIXIR_ERL_OPTIONS = "$Env:ELIXIR_ERL_OPTIONS"
306+
$ELIXIR_ERL_OPTIONS = "$env:ELIXIR_ERL_OPTIONS"
307307

308-
$AllParams = New-Object Collections.Generic.List[String]
308+
$allParams = New-Object Collections.Generic.List[String]
309309

310-
$AllParams.Add($ELIXIR_ERL_OPTIONS)
311-
$AllParams.AddRange($ErlangParams)
312-
$AllParams.AddRange($BeforeExtras)
313-
$AllParams.Add("-extra")
314-
$AllParams.AddRange($ElixirParams)
315-
$AllParams.AddRange($AllOtherParams)
310+
$allParams.Add($ELIXIR_ERL_OPTIONS)
311+
$allParams.AddRange($erlangParams)
312+
$allParams.AddRange($beforeExtras)
313+
$allParams.Add("-extra")
314+
$allParams.AddRange($elixirParams)
315+
$allParams.AddRange($allOtherParams)
316316

317-
$BinSuffix = ""
317+
$binSuffix = ""
318318

319-
if ($IsWindows) {
320-
$BinSuffix = ".exe"
319+
if ($isWindows) {
320+
$binSuffix = ".exe"
321321
}
322322

323-
$BinPath = "$ErlExec$BinSuffix"
323+
$binPath = "$erlExec$binSuffix"
324324

325325
if ($ERTS_BIN) {
326-
$BinPath = Join-Path -Path $ERTS_BIN -ChildPath $BinPath
326+
$binPath = Join-Path -Path $ERTS_BIN -ChildPath $binPath
327327
}
328328

329-
if ($null -eq $RunErlPipe) {
329+
if ($null -eq $runErlPipe) {
330330
# We double the double-quotes because they are going to be escaped by arguments parsing.
331-
$ParamsPart = $AllParams | ForEach-Object -Process { QuoteString($_ -replace "`"", "`"`"") }
331+
$paramsPart = $allParams | ForEach-Object -Process { QuoteString($_ -replace "`"", "`"`"") }
332332
}
333333
else {
334-
$private:OrigBinPath = $BinPath
335-
$ErlExec = "run_erl"
336-
$BinPath = "$ErlExec$BinSuffix"
334+
$allParams.Insert(0, $binPath)
335+
336+
$erlExec = "run_erl"
337+
$binPath = "$erlExec$binSuffix"
337338

338339
if ($ERTS_BIN) {
339-
$BinPath = Join-Path -Path $ERTS_BIN -ChildPath $BinPath
340+
$binPath = Join-Path -Path $ERTS_BIN -ChildPath $binPath
340341
}
341342

342-
$AllParams.Insert(0, $OrigBinPath)
343-
344343
# We scape special chars using the Unix style of scaping, with "\".
345344
# But first we escape the double-quotes.
346-
$private:Escaped = $AllParams | ForEach-Object -Process { ($_ -replace "`"", "\`"") -replace "[^a-zA-Z0-9_/-]", "\$&" }
345+
$private:escaped = $allParams | ForEach-Object -Process { ($_ -replace "`"", "\`"") -replace "[^a-zA-Z0-9_/-]", "\$&" }
347346

348347
# The args are surrounded here for the same reasons
349-
$ParamsPart = @("-daemon","`"$RunErlPipe/`"", "`"$RunErlLog/`"", "`"$($Escaped -join " ")`"")
348+
$paramsPart = @("-daemon","`"$runErlPipe/`"", "`"$runErlLog/`"", "`"$($escaped -join " ")`"")
350349
}
351350

352-
if ($Env:ELIXIR_CLI_DRY_RUN) {
353-
Write-Host "$BinPath $ParamsPart"
351+
if ($env:ELIXIR_CLI_DRY_RUN) {
352+
Write-Host "$binPath $paramsPart"
354353
}
355354
else {
356-
if ($RunErlPipe) {
357-
$null = New-Item -Path "." -ItemType "directory" -Name "$RunErlPipe" -Force
358-
$null = New-Item -Path "." -ItemType "directory" -Name "$RunErlLog" -Force
355+
if ($runErlPipe) {
356+
$null = New-Item -Path "." -ItemType "directory" -Name "$runErlPipe" -Force
357+
$null = New-Item -Path "." -ItemType "directory" -Name "$runErlLog" -Force
359358
}
360-
$Output = Start-Process -FilePath $BinPath -ArgumentList $ParamsPart -NoNewWindow -Wait -PassThru
361-
exit $Output.ExitCode
359+
$output = Start-Process -FilePath $binPath -ArgumentList $paramsPart -NoNewWindow -Wait -PassThru
360+
exit $output.ExitCode
362361
}

0 commit comments

Comments
 (0)