From 7c0b3b340fe31053905d4f19429169b11d5227a4 Mon Sep 17 00:00:00 2001 From: Stephen Kockentiedt Date: Thu, 19 May 2022 16:29:54 +0200 Subject: [PATCH] Allow not adding a Git repo when creating a new project (#388) --- Sources/VaporToolbox/New/New.swift | 31 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Sources/VaporToolbox/New/New.swift b/Sources/VaporToolbox/New/New.swift index 77cf0a68..b650ef92 100644 --- a/Sources/VaporToolbox/New/New.swift +++ b/Sources/VaporToolbox/New/New.swift @@ -18,6 +18,9 @@ struct New: AnyCommand { @Flag(name: "no-commit", help: "Skips adding a first commit to the newly created repo.") var noCommit: Bool + + @Flag(name: "no-git", help: "Skips adding a Git repository to the project folder.") + var noGit: Bool } let help = "Generates a new app." @@ -59,19 +62,21 @@ struct New: AnyCommand { throw "Too many arguments: \(context.input.arguments.joined(separator: " "))" } - // clear existing git history - let gitDir = workTree.appendingPathComponents(".git") - - context.console.info("Creating git repository") - if FileManager.default.fileExists(atPath: gitDir) { - try FileManager.default.removeItem(atPath: gitDir) - } - _ = try Process.git.create(gitDir: gitDir) - - // first commit - if !signature.noCommit { - context.console.info("Adding first commit") - try Process.git.commit(gitDir: gitDir, workTree: workTree, msg: "first commit") + if !signature.noGit { + // clear existing git history + let gitDir = workTree.appendingPathComponents(".git") + + context.console.info("Creating git repository") + if FileManager.default.fileExists(atPath: gitDir) { + try FileManager.default.removeItem(atPath: gitDir) + } + _ = try Process.git.create(gitDir: gitDir) + + // first commit + if !signature.noCommit { + context.console.info("Adding first commit") + try Process.git.commit(gitDir: gitDir, workTree: workTree, msg: "first commit") + } } // print the Droplet