Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/add-practice-exercise.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Remove-Item -Path "${exerciseDir}/UnitTest1.cs"
(Get-Content -Path ".editorconfig") -Replace "\[\*\.cs\]", "[${exerciseName}.cs]" | Set-Content -Path "${exerciseDir}/.editorconfig"

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

# Output the next steps
$files = Get-Content "exercises/practice/${Exercise}/.meta/config.json" | ConvertFrom-Json | Select-Object -ExpandProperty files
Expand Down
21 changes: 15 additions & 6 deletions bin/update-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
The slug of the exercise to generate the tests for (optional).
.PARAMETER CreateNew
Create a new test generator file before generating the tests (switch).
.PARAMETER SyncProbSpecs
Sync the prob-specs repo used (switch).
.EXAMPLE
The example below will generate the tests for exercises with a template
PS C:\> ./test.ps1
Expand All @@ -22,22 +24,29 @@ param (
[string]$Exercise,

[Parameter()]
[switch]$New
[switch]$New,

[Parameter()]
[switch]$SyncProbSpecs
)

$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true

function Run-Command($verb) {
if ($Exercise) {
& dotnet run --project generators $verb --exercise $Exercise
function Run-Command($verb, $exercise = $null) {
if ($exercise) {
& dotnet run --project generators $verb --exercise $exercise
} else {
& dotnet run --project generators $verb
}
}

if ($SyncProbSpecs.IsPresent) {
Run-Command sync
}

if ($New.IsPresent) {
Run-Command new
Run-Command new $Exercise
}

Run-Command update
Run-Command update $Exercise
1 change: 1 addition & 0 deletions generators/ProbSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ internal static class ProbSpecs
{
internal static void Sync()
{
Console.WriteLine($"Syncing problem-specifications repo...");
Clone();
Pull();
}
Expand Down
2 changes: 1 addition & 1 deletion generators/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Generators;
public static class Program
{
static void Main(string[] args) =>
Parser.Default.ParseArguments<NewOptions, UpdateOptions>(args)
Parser.Default.ParseArguments<NewOptions, UpdateOptions, SyncOptions>(args)
.WithParsed<NewOptions>(HandleNewCommand)
.WithParsed<UpdateOptions>(HandleUpdateCommand)
.WithParsed<SyncOptions>(HandleSyncCommand)
Expand Down
Loading