-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate-modjson.ps1
38 lines (32 loc) · 1.05 KB
/
validate-modjson.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$mod = "./mod.json"
if (-not (Test-Path -Path $mod)) {
if (Test-Path -Path ".\mod.template.json") {
& qpm-rust qmod build
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
}
else {
Write-Output "Error: mod.json and mod.template.json were not present"
exit 1
}
}
Write-Output "Creating qmod from mod.json"
$psVersion = $PSVersionTable.PSVersion.Major
if ($psVersion -ge 6) {
$schemaUrl = "https://raw.githubusercontent.com/Lauriethefish/QuestPatcher.QMod/main/QuestPatcher.QMod/Resources/qmod.schema.json"
Invoke-WebRequest $schemaUrl -OutFile ./mod.schema.json
$schema = "./mod.schema.json"
$modJsonRaw = Get-Content $mod -Raw
$modSchemaRaw = Get-Content $schema -Raw
Remove-Item $schema
Write-Output "Validating mod.json..."
if (-not ($modJsonRaw | Test-Json -Schema $modSchemaRaw)) {
Write-Output "Error: mod.json is not valid"
exit 1
}
}
else {
Write-Output "Could not validate mod.json with schema: powershell version was too low (< 6)"
}
exit