-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconfig.ps1
More file actions
executable file
·39 lines (30 loc) · 1.07 KB
/
config.ps1
File metadata and controls
executable file
·39 lines (30 loc) · 1.07 KB
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
39
# This script is used for patching the configuration of metacall with relative paths
param(
[string]$loc
)
# Use Unix path
$loc = $loc -replace '\\', '/'
# Get all JSON files in the configurations directory
$files = Get-ChildItem -Path "$loc/configurations" -Filter *.json
# Replace the global.json file, and anything that is pointing to configurations folder
foreach ($file in $files) {
# Read file as text
$content = Get-Content $file.FullName -Raw
# Replace "%loc%/./configurations/" with "./"
$pattern = [regex]::Escape("$loc/./configurations/")
$content = $content -replace $pattern, "./"
# Write the modified content back to the file
Set-Content $file.FullName $content
}
# Replace any other file pointing outside of configurations folder
foreach ($file in $files) {
# Read file as text
$content = Get-Content $file.FullName -Raw
# Replace "%loc%/" with "../"
$pattern = [regex]::Escape("$loc/")
$content = $content -replace $pattern, "../"
# Debug the files
Write-Host $content
# Write the modified content back to the file
Set-Content $file.FullName $content
}