Skip to content

Commit 2091caf

Browse files
Sync prob-specs from commands
1 parent a73fb25 commit 2091caf

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

bin/add-practice-exercise.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Remove-Item -Path "${exerciseDir}/UnitTest1.cs"
5454
(Get-Content -Path ".editorconfig") -Replace "\[\*\.cs\]", "[${exerciseName}.cs]" | Set-Content -Path "${exerciseDir}/.editorconfig"
5555

5656
# Create new generator template and run generator (this will update the tests file)
57-
bin/update-tests.ps1 -e $Exercise -new
57+
bin/update-tests.ps1 -Exercise $Exercise -New -SyncProbSpecs
5858

5959
# Output the next steps
6060
$files = Get-Content "exercises/practice/${Exercise}/.meta/config.json" | ConvertFrom-Json | Select-Object -ExpandProperty files

bin/update-tests.ps1

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
The slug of the exercise to generate the tests for (optional).
99
.PARAMETER CreateNew
1010
Create a new test generator file before generating the tests (switch).
11+
.PARAMETER SyncProbSpecs
12+
Sync the prob-specs repo used (switch).
1113
.EXAMPLE
1214
The example below will generate the tests for exercises with a template
1315
PS C:\> ./test.ps1
@@ -22,22 +24,29 @@ param (
2224
[string]$Exercise,
2325

2426
[Parameter()]
25-
[switch]$New
27+
[switch]$New,
28+
29+
[Parameter()]
30+
[switch]$SyncProbSpecs
2631
)
2732

2833
$ErrorActionPreference = "Stop"
2934
$PSNativeCommandUseErrorActionPreference = $true
3035

31-
function Run-Command($verb) {
32-
if ($Exercise) {
33-
& dotnet run --project generators $verb --exercise $Exercise
36+
function Run-Command($verb, $exercise = $null) {
37+
if ($exercise) {
38+
& dotnet run --project generators $verb --exercise $exercise
3439
} else {
3540
& dotnet run --project generators $verb
3641
}
3742
}
3843

44+
if ($SyncProbSpecs.IsPresent) {
45+
Run-Command sync
46+
}
47+
3948
if ($New.IsPresent) {
40-
Run-Command new
49+
Run-Command new $Exercise
4150
}
4251

43-
Run-Command update
52+
Run-Command update $Exercise

generators/ProbSpecs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ internal static class ProbSpecs
66
{
77
internal static void Sync()
88
{
9+
Console.WriteLine($"Syncing problem-specifications repo...");
910
Clone();
1011
Pull();
1112
}

0 commit comments

Comments
 (0)