-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.run-csharpier.ps1
53 lines (39 loc) · 1.6 KB
/
.run-csharpier.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
param([string]$file)
# Define the directory to check
$directoryToCheck = "Assets/Resources/CVRFury/nvhpmm/AppComponents/"
# Get the directory of the script
$scriptDirectory = Split-Path $PSCommandPath
# concatenate the script directory with the file
$file = Join-Path $scriptDirectory $file
# concatenate the script directory with the directory to check
$directoryToCheck = Join-Path $scriptDirectory $directoryToCheck
# Check if the file is the specified directory
if ($file.StartsWith($directoryToCheck)) {
$fileName = [System.IO.Path]::GetFileName($file)
# print the file name to the console
Write-Host "File Name: $fileName"
# get the path of the $file excluding the file name+extension
$filePath = [System.IO.Path]::GetDirectoryName($file)
# print the file path to the console
Write-Host "File Path: $filePath"
# check if the fileName ends with .cs.source
if ($fileName -match "\.cs\.source$")
{
# remove the .source extension
$newFileName = $fileName -replace '\.source$', ''
# concatenate the file path with the new file name
$newFileName = Join-Path $filePath $newFileName
# rename the file to .cs
Rename-Item -Path $file -NewName $newFileName
# trigger the csharpier command
Write-Host "Running csharpier on $newFileName"
dotnet csharpier $newFileName
# rename the file back to .cs.source
Rename-Item -Path $newFileName -NewName $file
}
}
else {
# not in the specified directory, so will need to handle normal csharpier command
Write-Host "Running csharpier on $file"
dotnet csharpier $file
}