2
2
3
3
$ELIXIR_VERSION = " 1.17.0-dev"
4
4
5
- $MinPowerShellVersion = [version ]" 7.2.0"
5
+ $minPowerShellVersion = [version ]" 7.2.0"
6
6
7
- if ($MinPowerShellVersion .CompareTo ([version ]$PSVersionTable.PSVersion ) -eq 1 ) {
7
+ if ($minPowerShellVersion .CompareTo ([version ]$PSVersionTable.PSVersion ) -eq 1 ) {
8
8
Write-Error " This script requires PowerShell version 7.2 or above. Running on $ ( $PSVersionTable.PSVersion ) "
9
9
}
10
10
11
- $ScriptPath = Split-Path - Parent $PSCommandPath
12
- $ErlExec = " erl"
11
+ $scriptPath = Split-Path - Parent $PSCommandPath
12
+ $erlExec = " erl"
13
13
14
14
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]
18
18
19
19
## General options
20
20
@@ -69,15 +69,15 @@ See run_erl to learn more. To reattach, run: to_erl PIPEDIR.
69
69
** Standalone options can't be combined with other options.
70
70
"@
71
71
72
- Write-Host $Help
72
+ Write-Host $help
73
73
}
74
74
75
- if (($Args .Count -eq 1 ) -and ($Args [0 ] -eq " --short-version" )) {
75
+ if (($args .Count -eq 1 ) -and ($args [0 ] -eq " --short-version" )) {
76
76
Write-Host " $ELIXIR_VERSION "
77
77
exit
78
78
}
79
79
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" )))) {
81
81
PrintElixirHelp
82
82
exit 1
83
83
}
@@ -109,172 +109,172 @@ function QuoteString {
109
109
}
110
110
}
111
111
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 ]
116
116
117
- $RunErlPipe = $null
118
- $RunErlLog = $null
117
+ $runErlPipe = $null
118
+ $runErlLog = $null
119
119
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 ]
122
122
123
- switch ($Arg ) {
123
+ switch ($arg ) {
124
124
{ $_ -in @ (" -e" , " -r" , " -pr" , " -pa" , " -pz" , " --eval" , " --remsh" , " --dot-iex" , " --dbg" ) } {
125
- $private :NextArg = NormalizeArg($Args [++ $i ])
125
+ $private :nextArg = NormalizeArg($args [++ $i ])
126
126
127
- $ElixirParams .Add ($Arg )
128
- $ElixirParams .Add ($NextArg )
127
+ $elixirParams .Add ($arg )
128
+ $elixirParams .Add ($nextArg )
129
129
130
130
break
131
131
}
132
132
133
133
{ $_ -in @ (" -v" , " --version" ) } {
134
134
# 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 )
137
137
}
138
138
else {
139
- $AllOtherParams .Add ($Arg )
139
+ $allOtherParams .Add ($arg )
140
140
}
141
141
break
142
142
}
143
143
144
144
" --no-halt" {
145
- $ElixirParams .Add ($Arg )
145
+ $elixirParams .Add ($arg )
146
146
break
147
147
}
148
148
149
149
" --cookie" {
150
- $ErlangParams .Add (" -setcookie" )
151
- $ErlangParams .Add ($Args [++ $i ])
150
+ $erlangParams .Add (" -setcookie" )
151
+ $erlangParams .Add ($args [++ $i ])
152
152
break
153
153
}
154
154
155
155
" --hidden" {
156
- $ErlangParams .Add (" -hidden" )
156
+ $erlangParams .Add (" -hidden" )
157
157
break
158
158
}
159
159
160
160
" --name" {
161
- $ErlangParams .Add (" -name" )
162
- $ErlangParams .Add ($Args [++ $i ])
161
+ $erlangParams .Add (" -name" )
162
+ $erlangParams .Add ($args [++ $i ])
163
163
break
164
164
}
165
165
166
166
" --sname" {
167
- $ErlangParams .Add (" -sname" )
168
- $ErlangParams .Add ($Args [++ $i ])
167
+ $erlangParams .Add (" -sname" )
168
+ $erlangParams .Add ($args [++ $i ])
169
169
break
170
170
}
171
171
172
172
" --boot" {
173
- $ErlangParams .Add (" -boot" )
174
- $ErlangParams .Add ($Args [++ $i ])
173
+ $erlangParams .Add (" -boot" )
174
+ $erlangParams .Add ($args [++ $i ])
175
175
break
176
176
}
177
177
178
178
" --erl-config" {
179
- $ErlangParams .Add (" -config" )
180
- $ErlangParams .Add ($Args [++ $i ])
179
+ $erlangParams .Add (" -config" )
180
+ $erlangParams .Add ($args [++ $i ])
181
181
break
182
182
}
183
183
184
184
" --vm-args" {
185
- $ErlangParams .Add (" -args_file" )
186
- $ErlangParams .Add ($Args [++ $i ])
185
+ $erlangParams .Add (" -args_file" )
186
+ $erlangParams .Add ($args [++ $i ])
187
187
break
188
188
}
189
189
190
190
" --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 ]))
194
194
}
195
195
break
196
196
}
197
197
198
198
" --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 ]))
202
202
}
203
203
break
204
204
}
205
205
206
206
" --erl" {
207
- $BeforeExtras .Add ($Args [++ $i ])
207
+ $beforeExtras .Add ($args [++ $i ])
208
208
break
209
209
}
210
210
211
211
" +iex" {
212
- $ElixirParams .Add (" +iex" )
213
- $UseIex = $true
212
+ $elixirParams .Add (" +iex" )
213
+ $useIex = $true
214
214
215
215
break
216
216
}
217
217
218
218
" +elixirc" {
219
- $ElixirParams .Add (" +elixirc" )
219
+ $elixirParams .Add (" +elixirc" )
220
220
break
221
221
}
222
222
223
223
" --rpc-eval" {
224
- $private :Key = $Args [++ $i ]
225
- $private :Value = $Args [++ $i ]
224
+ $private :key = $args [++ $i ]
225
+ $private :value = $args [++ $i ]
226
226
227
- if ($null -eq $Key ) {
227
+ if ($null -eq $key ) {
228
228
Write-Error " --rpc-eval: NODE must be present"
229
229
exit 1
230
230
}
231
231
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"
234
234
exit 1
235
235
}
236
236
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 )
240
240
break
241
241
}
242
242
243
243
" --boot-var" {
244
- $private :Key = $Args [++ $i ]
245
- $private :Value = $Args [++ $i ]
244
+ $private :key = $args [++ $i ]
245
+ $private :value = $args [++ $i ]
246
246
247
- if ($null -eq $Key ) {
247
+ if ($null -eq $key ) {
248
248
Write-Error " --boot-var: VAR must be present"
249
249
exit 1
250
250
}
251
251
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"
254
254
exit 1
255
255
}
256
256
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 )
260
260
break
261
261
}
262
262
263
263
" --pipe-to" {
264
- $RunErlPipe = $Args [++ $i ]
265
- $RunErlLog = $Args [++ $i ]
264
+ $runErlPipe = $args [++ $i ]
265
+ $runErlLog = $args [++ $i ]
266
266
267
- if ($null -eq $RunErlPipe ) {
267
+ if ($null -eq $runErlPipe ) {
268
268
Write-Error " --pipe-to: PIPEDIR must be present"
269
269
exit 1
270
270
}
271
271
272
- if ($null -eq $RunErlLog ) {
272
+ if ($null -eq $runErlLog ) {
273
273
Write-Error " --pipe-to: PIPELOG must be present"
274
274
exit 1
275
275
}
276
276
277
- if ($RunErlPipe .EndsWith (" /" ) -or $RunErlLog .EndsWith (" /" )) {
277
+ if ($runErlPipe .EndsWith (" /" ) -or $runErlLog .EndsWith (" /" )) {
278
278
Write-Error " --pipe-to: PIPEDIR and PIPELOG must not end with a slash"
279
279
exit 1
280
280
}
@@ -283,80 +283,79 @@ for ($i = 0; $i -lt $Args.Count; $i++) {
283
283
}
284
284
285
285
Default {
286
- $private :Normalized = NormalizeArg $Arg
287
- $AllOtherParams .Add ($Normalized )
286
+ $private :normalized = NormalizeArg $arg
287
+ $allOtherParams .Add ($normalized )
288
288
break
289
289
}
290
290
}
291
291
}
292
292
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" ))
295
295
}
296
296
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" ) " ))
299
299
300
300
# One MAY change ERTS_BIN= but you MUST NOT change
301
301
# ERTS_BIN=$ERTS_BIN as it is handled by Elixir releases.
302
302
# TODO: change when we port the releases scripts.
303
303
# $ERTS_BIN=
304
- $ERTS_BIN = " $Env : ERTS_BIN "
304
+ $ERTS_BIN = " $env : ERTS_BIN "
305
305
306
- $ELIXIR_ERL_OPTIONS = " $Env : ELIXIR_ERL_OPTIONS "
306
+ $ELIXIR_ERL_OPTIONS = " $env : ELIXIR_ERL_OPTIONS "
307
307
308
- $AllParams = New-Object Collections.Generic.List[String ]
308
+ $allParams = New-Object Collections.Generic.List[String ]
309
309
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 )
316
316
317
- $BinSuffix = " "
317
+ $binSuffix = " "
318
318
319
- if ($IsWindows ) {
320
- $BinSuffix = " .exe"
319
+ if ($isWindows ) {
320
+ $binSuffix = " .exe"
321
321
}
322
322
323
- $BinPath = " $ErlExec$BinSuffix "
323
+ $binPath = " $erlExec$binSuffix "
324
324
325
325
if ($ERTS_BIN ) {
326
- $BinPath = Join-Path - Path $ERTS_BIN - ChildPath $BinPath
326
+ $binPath = Join-Path - Path $ERTS_BIN - ChildPath $binPath
327
327
}
328
328
329
- if ($null -eq $RunErlPipe ) {
329
+ if ($null -eq $runErlPipe ) {
330
330
# 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 " `" " , " `"`" " ) }
332
332
}
333
333
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 "
337
338
338
339
if ($ERTS_BIN ) {
339
- $BinPath = Join-Path - Path $ERTS_BIN - ChildPath $BinPath
340
+ $binPath = Join-Path - Path $ERTS_BIN - ChildPath $binPath
340
341
}
341
342
342
- $AllParams.Insert (0 , $OrigBinPath )
343
-
344
343
# We scape special chars using the Unix style of scaping, with "\".
345
344
# 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_/-]" , " \$&" }
347
346
348
347
# The args are surrounded here for the same reasons
349
- $ParamsPart = @ (" -daemon" , " `" $RunErlPipe /`" " , " `" $RunErlLog /`" " , " `" $ ( $Escaped -join " " ) `" " )
348
+ $paramsPart = @ (" -daemon" , " `" $runErlPipe /`" " , " `" $runErlLog /`" " , " `" $ ( $escaped -join " " ) `" " )
350
349
}
351
350
352
- if ($Env : ELIXIR_CLI_DRY_RUN ) {
353
- Write-Host " $BinPath $ParamsPart "
351
+ if ($env : ELIXIR_CLI_DRY_RUN ) {
352
+ Write-Host " $binPath $paramsPart "
354
353
}
355
354
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
359
358
}
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
362
361
}
0 commit comments