-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix.ps1
More file actions
29 lines (22 loc) · 909 Bytes
/
fix.ps1
File metadata and controls
29 lines (22 loc) · 909 Bytes
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
# Define the path to the search.ts file
$searchTsPath = "C:\projects\expressentry\pages\api\search.ts"
# Read the content of the file
$content = Get-Content $searchTsPath -Raw
# Define the problematic string pattern
$problemPattern = 'const { query, matches } = \(await req.json\(\)\) as \{
console.log\(''Request body:'', \{ query, matches \}\);
query: string;
matches: number;
\};'
# Define the corrected string
$correctedString = 'const body = (await req.json()) as {
query: string;
matches: number;
};
const { query, matches } = body;
console.log(''Request body:'', { query, matches });'
# Replace the problematic pattern with the corrected string
$correctedContent = $content -replace [regex]::Escape($problemPattern), $correctedString
# Write the corrected content back to the file
Set-Content -Path $searchTsPath -Value $correctedContent
Write-Host "The search.ts file has been updated."