From 51fa3f5a4e370b6778d6a59acbc3377d213570af Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Tue, 1 Apr 2025 02:06:53 +0800 Subject: [PATCH] Refactor command handling in TypeScript starter templates to remove enum for 'init' command, simplifying the switch case structure. --- compiled_starters/typescript/app/main.ts | 6 +----- solutions/typescript/01-gg4/code/app/main.ts | 6 +----- solutions/typescript/01-gg4/diff/app/main.ts.diff | 8 ++------ starter_templates/typescript/code/app/main.ts | 6 +----- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/compiled_starters/typescript/app/main.ts b/compiled_starters/typescript/app/main.ts index b0c8698..0a44704 100644 --- a/compiled_starters/typescript/app/main.ts +++ b/compiled_starters/typescript/app/main.ts @@ -3,12 +3,8 @@ import * as fs from 'fs'; const args = process.argv.slice(2); const command = args[0]; -enum Commands { - Init = "init", -} - switch (command) { - case Commands.Init: + case "init": // You can use print statements as follows for debugging, they'll be visible when running tests. console.error("Logs from your program will appear here!"); diff --git a/solutions/typescript/01-gg4/code/app/main.ts b/solutions/typescript/01-gg4/code/app/main.ts index 4873ae9..d3f1913 100644 --- a/solutions/typescript/01-gg4/code/app/main.ts +++ b/solutions/typescript/01-gg4/code/app/main.ts @@ -3,12 +3,8 @@ import * as fs from 'fs'; const args = process.argv.slice(2); const command = args[0]; -enum Commands { - Init = "init", -} - switch (command) { - case Commands.Init: + case "init": fs.mkdirSync(".git", { recursive: true }); fs.mkdirSync(".git/objects", { recursive: true }); fs.mkdirSync(".git/refs", { recursive: true }); diff --git a/solutions/typescript/01-gg4/diff/app/main.ts.diff b/solutions/typescript/01-gg4/diff/app/main.ts.diff index 8be0355..f51a5ee 100644 --- a/solutions/typescript/01-gg4/diff/app/main.ts.diff +++ b/solutions/typescript/01-gg4/diff/app/main.ts.diff @@ -1,15 +1,11 @@ -@@ -1,24 +1,20 @@ +@@ -1,20 +1,16 @@ import * as fs from 'fs'; const args = process.argv.slice(2); const command = args[0]; - enum Commands { - Init = "init", - } - switch (command) { - case Commands.Init: + case "init": - // You can use print statements as follows for debugging, they'll be visible when running tests. - console.error("Logs from your program will appear here!"); - diff --git a/starter_templates/typescript/code/app/main.ts b/starter_templates/typescript/code/app/main.ts index b0c8698..0a44704 100644 --- a/starter_templates/typescript/code/app/main.ts +++ b/starter_templates/typescript/code/app/main.ts @@ -3,12 +3,8 @@ import * as fs from 'fs'; const args = process.argv.slice(2); const command = args[0]; -enum Commands { - Init = "init", -} - switch (command) { - case Commands.Init: + case "init": // You can use print statements as follows for debugging, they'll be visible when running tests. console.error("Logs from your program will appear here!");