-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcopy-devtotemplate.ps1
29 lines (23 loc) · 1.11 KB
/
copy-devtotemplate.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
cd $PSScriptRoot
gci templates\*.dev -Directory | foreach {
$sourceDirectory = $_.FullName
"Source directory: $sourceDirectory"
$destinationDirectory = $sourceDirectory.Replace(".Dev", "")
"Destination directory: $destinationDirectory"
gci "$sourceDirectory\*" -Include *.cs, *.vb, app.config | foreach {
copy $_.FullName $destinationDirectory -Verbose
}
gci "$destinationDirectory\*" -Include *.cs, *.vb, app.config | foreach {
"Fixing $($_.FullName)"
$content = [System.IO.File]::ReadAllText($_.FullName)
$content = [System.Text.RegularExpressions.Regex]::Replace($content, "(?<prefix>//|<!--)\s*TODO:\s*?(?<whatiwant>.*).*(?<ending>-->)?.*(?<newline>\n)(?<possibleblank>^\s*)(?<toreplace>.*)\n", "`$2", [System.Text.RegularExpressions.RegexOptions]::Multiline)
[System.IO.File]::WriteAllText($_.FullName, $content)
}
}
gci templates\all -File | % {
$file = $_.FullName
$name = $_.Name
gci templates -Directory | where { $_.Name -notmatch "All|HomeSeerTemplates"} | % {
copy-item $file -Destination $_.FullName -Force -Verbose
}
}