Skip to content

Commit

Permalink
Allow not adding a Git repo when creating a new project (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-k authored May 19, 2022
1 parent 6e6e083 commit 7c0b3b3
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions Sources/VaporToolbox/New/New.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7c0b3b3

Please sign in to comment.