forked from exercism/csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy-track-files.ps1
45 lines (36 loc) · 1.35 KB
/
copy-track-files.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
<#
.SYNOPSIS
Copy track files.
.DESCRIPTION
Copy global, track-specific files that are applicable to each exercise.
.PARAMETER Exercise
The slug of the exercise to be analyzed (optional).
.EXAMPLE
The example below will copy the track-specific files to all exercises
PS C:\> ./copy-track-files.ps1
.EXAMPLE
The example below will copy the track-specific files to the "acronym" exercise
PS C:\> ./copy-track-files.ps1 acronym
#>
param (
[Parameter(Position = 0, Mandatory = $false)]
[string]$Exercise
)
# Import shared functionality
. ./shared.ps1
$defaultEditorConfigSettings = Get-Content -Path ".editorconfig"
function Copy-Track-Files-For-Exercise ($ExerciseDirectory) {
$exerciseName = (Get-Culture).TextInfo.ToTitleCase($ExerciseDirectory.Name).Replace("-", "")
$editorConfigSettings = $defaultEditorConfigSettings.Replace( "[*.cs]", "[${exerciseName}.cs]")
$exerciseEditorConfigPath = Join-Path $ExerciseDirectory.FullName ".editorconfig"
Set-Content -Path $exerciseEditorConfigPath $editorConfigSettings
}
function Copy-Track-Files {
Write-Output "Copying track files"
$filter = if ($Exercise) { $($Exercise) } else { @() }
Get-Childitem –Path "exercises" -Filter $filter -Directory | ForEach-Object {
Copy-Track-Files-For-Exercise -ExerciseDirectory $_
}
}
Copy-Track-Files
exit $LastExitCode