Skip to content

Commit 687ee83

Browse files
abcdefg30pchote
authored andcommitted
Don't ignore user.config in make.ps1
1 parent 8eb6a68 commit 687ee83

File tree

1 file changed

+31
-43
lines changed

1 file changed

+31
-43
lines changed

Diff for: make.ps1

+31-43
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,30 @@ function WaitForInput
199199
}
200200
}
201201

202+
function ReadConfigLine($line, $name)
203+
{
204+
if ($line.StartsWith($name))
205+
{
206+
$prefix = $name + '='
207+
[Environment]::SetEnvironmentVariable($name, $line.Replace($prefix, '').Replace('"', ''))
208+
}
209+
}
210+
211+
function ParseConfigFile($fileName)
212+
{
213+
$names = @("MOD_ID", "INCLUDE_DEFAULT_MODS", "ENGINE_VERSION", "AUTOMATIC_ENGINE_MANAGEMENT", "AUTOMATIC_ENGINE_SOURCE",
214+
"AUTOMATIC_ENGINE_EXTRACT_DIRECTORY", "AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME", "ENGINE_DIRECTORY")
215+
216+
$reader = [System.IO.File]::OpenText($fileName)
217+
while($null -ne ($line = $reader.ReadLine()))
218+
{
219+
foreach ($name in $names)
220+
{
221+
ReadConfigLine $line $name
222+
}
223+
}
224+
}
225+
202226
###############################################################
203227
############################ Main #############################
204228
###############################################################
@@ -225,51 +249,15 @@ else
225249

226250
# Load the environment variables from the config file
227251
# and get the mod ID from the local environment variable
228-
$reader = [System.IO.File]::OpenText("mod.config")
229-
while($null -ne ($line = $reader.ReadLine()))
230-
{
231-
if ($line.StartsWith("MOD_ID"))
232-
{
233-
$env:MOD_ID = $line.Replace('MOD_ID=', '').Replace('"', '')
234-
$modID = $env:MOD_ID
235-
}
236-
237-
if ($line.StartsWith("INCLUDE_DEFAULT_MODS"))
238-
{
239-
$env:INCLUDE_DEFAULT_MODS = $line.Replace('INCLUDE_DEFAULT_MODS=', '').Replace('"', '')
240-
}
252+
ParseConfigFile "mod.config"
241253

242-
if ($line.StartsWith("ENGINE_VERSION"))
243-
{
244-
$env:ENGINE_VERSION = $line.Replace('ENGINE_VERSION=', '').Replace('"', '')
245-
}
246-
247-
if ($line.StartsWith("AUTOMATIC_ENGINE_MANAGEMENT"))
248-
{
249-
$env:AUTOMATIC_ENGINE_MANAGEMENT = $line.Replace('AUTOMATIC_ENGINE_MANAGEMENT=', '').Replace('"', '')
250-
}
251-
252-
if ($line.StartsWith("AUTOMATIC_ENGINE_SOURCE"))
253-
{
254-
$env:AUTOMATIC_ENGINE_SOURCE = $line.Replace('AUTOMATIC_ENGINE_SOURCE=', '').Replace('"', '')
255-
}
256-
257-
if ($line.StartsWith("AUTOMATIC_ENGINE_EXTRACT_DIRECTORY"))
258-
{
259-
$env:AUTOMATIC_ENGINE_EXTRACT_DIRECTORY = $line.Replace('AUTOMATIC_ENGINE_EXTRACT_DIRECTORY=', '').Replace('"', '')
260-
}
261-
262-
if ($line.StartsWith("AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME"))
263-
{
264-
$env:AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME = $line.Replace('AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME=', '').Replace('"', '')
265-
}
266-
267-
if ($line.StartsWith("ENGINE_DIRECTORY"))
268-
{
269-
$env:ENGINE_DIRECTORY = $line.Replace('ENGINE_DIRECTORY=', '').Replace('"', '')
270-
}
254+
if (Test-Path "user.config")
255+
{
256+
ParseConfigFile "user.config"
271257
}
272258

259+
$modID = $env:MOD_ID
260+
273261
$env:MOD_SEARCH_PATHS = (Get-Item -Path ".\" -Verbose).FullName + "\mods"
274262
if ($env:INCLUDE_DEFAULT_MODS -eq "True")
275263
{
@@ -326,7 +314,7 @@ if ($command -eq "all" -or $command -eq "clean")
326314
$dlPath = Join-Path $pwd (Split-Path -leaf $env:AUTOMATIC_ENGINE_EXTRACT_DIRECTORY)
327315
$dlPath = Join-Path $dlPath (Split-Path -leaf $env:AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME)
328316

329-
$client = new-object System.Net.WebClient
317+
$client = new-object System.Net.WebClient
330318
$client.DownloadFile($url, $dlPath)
331319

332320
Add-Type -assembly "system.io.compression.filesystem"

0 commit comments

Comments
 (0)