src/main/scala/s3/website/model/ssg.scala in s3_website-2.1.16 vs src/main/scala/s3/website/model/ssg.scala in s3_website-2.2.0

- old
+ new

@@ -1,28 +1,22 @@ package s3.website.model import java.io.File +import s3.website.model.Files.recursiveListFiles import s3.website.{ErrorOrFile, ErrorReport} // ssg = static site generator trait Ssg { def outputDirectory: String } object Ssg { val automaticallySupportedSiteGenerators = Jekyll :: Nanoc :: Nil - val notFoundErrorReport = - new ErrorReport { - def reportMessage = - """|Could not find a website in any of the pre-defined directories. - |Specify the website location with the --site=path argument and try again.""".stripMargin + def autodetectSiteDir(workingDirectory: File): Option[File] = + recursiveListFiles(workingDirectory).find { file => + file.isDirectory && automaticallySupportedSiteGenerators.exists(ssg => file.getAbsolutePath.endsWith(ssg.outputDirectory)) } - - def findSiteDirectory(workingDirectory: File): ErrorOrFile = - Files.recursiveListFiles(workingDirectory).find { file => - file.isDirectory && automaticallySupportedSiteGenerators.exists(_.outputDirectory == file.getName) - }.fold(Left(notFoundErrorReport): ErrorOrFile)(Right(_)) } case object Jekyll extends Ssg { def outputDirectory = "_site" } \ No newline at end of file