1
+ # ### Initializations
2
+ $cd = (Get-Item - Path " .\" - Verbose).FullName
3
+ $isccDefine = " "
4
+ $isccDir = " "
5
+ $elixirVersion = " "
6
+ $startInstaller = 0
7
+ $friendly = 0
8
+
1
9
# ### Output functions
2
10
function Err ($str )
3
11
{
@@ -9,73 +17,104 @@ function Info ($str)
9
17
Write-Host " Info | " - foregroundcolor " green" - NoNewline
10
18
Write-Host " $str "
11
19
}
12
- function ExitMsg ()
20
+ function FriendlyPause ()
13
21
{
14
22
Err(" Something went wrong while making the offline installer. Elixir was not installed to your computer." )
15
23
Err(" You can report this issue at https://github.com/chyndman/elixir-windows-setup/issues" )
16
24
Write-Host " " - NoNewline
17
25
pause
26
+ }
27
+ function ErrExit ($str )
28
+ {
29
+ if ($friendly -eq 1 )
30
+ {
31
+ FriendlyPause
32
+ }
18
33
exit
19
34
}
20
35
21
- # ### Initializations
22
- $cd = (Get-Item - Path " .\" - Verbose).FullName
23
- $isccDefine = " "
24
- $isccDir = $cd
25
- $elixirVersion = " "
26
- $startInstaller = 0
27
-
28
36
# ### Script
29
37
Info(" Current directory:" )
30
38
Info(" $cd " )
31
39
32
40
Info(" Reading arguments..." )
33
- foreach ($arg in $ args )
41
+ for ($i = 0 ; $i -lt $ args.length ; $i ++ )
34
42
{
35
- Info(" $arg " )
36
- if ($arg = " --innoelixirweb" )
43
+ Info(" " + $args [$i ])
44
+ if ($args [$i ] -eq " --friendly" )
45
+ {
46
+ $friendly = 1
47
+ }
48
+ if ($args [$i ] -eq " --skip-welcome" )
49
+ {
50
+ $isccDefine += " /dSkipWelcome"
51
+ }
52
+ if ($args [$i ] -eq " --no-compression" )
53
+ {
54
+ $isccDefine += " /dNoCompression"
55
+ }
56
+ if ($args [$i ] -eq " --start" )
37
57
{
38
- $isccDefine = " /dSkipPages /dNoCompression"
39
58
$startInstaller = 1
40
59
}
60
+ if ($args [$i ] -eq " --isccdir" )
61
+ {
62
+ $i ++
63
+ if ($args [$i ] -ne $null )
64
+ {
65
+ Info(" " + $args [$i ])
66
+ $isccDir = $args [$i ]
67
+ }
68
+ else
69
+ {
70
+ ErrExit(" Invalid arguments" )
71
+ }
72
+ }
41
73
}
42
74
Info(" Finished reading arguments" )
43
75
44
- Info(" Checking for ISCC.exe in $isccDir ... " )
45
- if ( Test-Path $isccDir \ ISCC.exe )
76
+ Info(" Checking for ISCC.exe in: " )
77
+ foreach ( $dir in ( $isccDir , $cd , " C:\Program Files (x86)\Inno Setup 5 " , $null ) )
46
78
{
47
- Info(" ISCC path: $isccDir \ISCC.exe" )
48
- }
49
- else
50
- {
51
- Err(" ISCC.exe not found in $isccDir " )
52
- ExitMsg
79
+ if ($dir -eq $null )
80
+ {
81
+ ErrExit(" ISCC.exe not found" )
82
+ }
83
+ if ($dir -ne " " )
84
+ {
85
+ Info(" $dir " )
86
+ if (Test-Path $dir \ISCC.exe )
87
+ {
88
+ $isccDir = $dir
89
+ Info(" ISCC path: $isccDir \ISCC.exe" )
90
+ break ;
91
+ }
92
+ }
53
93
}
54
94
55
- Info(" Checking for elixir directory ..." )
56
- if (Test-Path . \elixir)
95
+ Info(" Checking for $cd \ elixir..." )
96
+ if (Test-Path $cd \elixir)
57
97
{
58
- Info(" elixir directory exists" )
98
+ Info(" $cd \ elixir exists" )
59
99
}
60
100
else
61
101
{
62
- Info(" Not found, checking for Precompiled.zip..." )
63
- if (Test-Path . \Precompiled.zip)
102
+ Info(" Not found, checking for $cd \ Precompiled.zip..." )
103
+ if (Test-Path $cd \Precompiled.zip)
64
104
{
65
- Info(" Precompiled.zip found" )
66
- Info(" Extracting Precompiled.zip to . \elixir..." )
105
+ Info(" $cd \ Precompiled.zip found" )
106
+ Info(" Extracting $cd \ Precompiled.zip to $cd \elixir..." )
67
107
scripts\extract- zip.ps1 $cd \Precompiled.zip $cd \elixir
68
108
}
69
109
else
70
110
{
71
- Err(" Precompiled.zip not found" )
72
- ExitMsg
111
+ ErrExit(" $cd \Precompiled.zip not found" )
73
112
}
74
113
}
75
114
76
115
if ($elixirVersion -eq " " )
77
116
{
78
- Info(" Reading Elixir version from elixir\VERSION..." )
117
+ Info(" Reading Elixir version from $cd \ elixir\VERSION..." )
79
118
foreach ($line in (Get-Content $cd \elixir\VERSION))
80
119
{
81
120
$elixirVersion = $line
@@ -86,20 +125,21 @@ if ($elixirVersion -eq "")
86
125
87
126
$isccDefine = " `" /dElixirVersion=" + $elixirVersion + " `" " + $isccDefine
88
127
128
+ $isccDefine = $isccDefine.Trim ()
89
129
Info(" Running $isccDir \ISCC.exe $isccDefine /Q Elixir.iss" )
90
130
& $isccDir \ISCC.exe $isccDefine / Q Elixir.iss
131
+
91
132
if ($LastExitCode -eq 0 )
92
133
{
93
- Info(" Installer compiled successfully to . \Output\elixir-v$elixirVersion -setup.exe" )
134
+ Info(" Installer compiled successfully to $cd \Output\elixir-v$elixirVersion -setup.exe" )
94
135
}
95
136
else
96
137
{
97
- Err(" ISCC.exe failed with exit code $LastExitCode " )
98
- ExitMsg
138
+ ErrExit(" ISCC.exe failed with exit code $LastExitCode " )
99
139
}
100
140
101
141
if ($startInstaller -eq 1 )
102
142
{
103
143
Info(" Starting installer..." )
104
- start " . \Output\elixir-v$elixirVersion -setup.exe"
144
+ start " $cd \Output\elixir-v$elixirVersion -setup.exe"
105
145
}
0 commit comments