@@ -311,18 +311,14 @@ extension SwiftPackageTool {
311
311
guard let configPath = try swiftTool. getConfigPath ( ) else {
312
312
throw InternalError ( " Could not find config path " )
313
313
}
314
-
315
- guard let cwd = localFileSystem. currentWorkingDirectory else {
316
- throw InternalError ( " Could not get the current working directory " )
317
- }
318
-
314
+
319
315
if let path = try ? AbsolutePath ( validating: url) {
320
316
if localFileSystem. exists ( path) {
321
317
let currentTemplateLocation = path
322
318
let templateDirectory = configPath. appending ( components: " templates " , " new-package " , url)
323
319
324
320
guard localFileSystem. exists ( currentTemplateLocation) && localFileSystem. isDirectory ( currentTemplateLocation) else {
325
- throw InternalError ( " Template folder \( url ) could not be found in : \( cwd ) " )
321
+ throw StringError ( " Could not find template : \( url ) " )
326
322
}
327
323
328
324
try localFileSystem. copy ( from: currentTemplateLocation, to: templateDirectory)
@@ -360,13 +356,17 @@ extension SwiftPackageTool {
360
356
}
361
357
362
358
guard localFileSystem. exists ( configPath. appending ( components: " templates " , " new-package " , templateName) ) else {
363
- throw InternalError ( " Could not find \( templateName) " )
359
+ throw StringError ( " Could not find template: \( templateName) " )
364
360
}
365
361
366
362
let provider = GitRepositoryProvider ( )
367
363
let templatePath = configPath. appending ( components: " templates " , " new-package " , templateName)
368
364
369
- try provider. pull ( repository: RepositorySpecifier ( url: templatePath. pathString) , to: templatePath)
365
+ if provider. isValidDirectory ( templatePath. pathString) {
366
+ try provider. pull ( templatePath. pathString)
367
+ } else {
368
+ throw StringError ( " Template: \( templateName) is not a git repo, and therefore could not be updated " )
369
+ }
370
370
}
371
371
}
372
372
0 commit comments