Skip to content

Commit

Permalink
Merge pull request #452 from magneticflux-/fix-windows-fileseparator-…
Browse files Browse the repository at this point in the history
…regex

Fix windows file separator regex
  • Loading branch information
eed3si9n authored Dec 30, 2019
2 parents fc7f43e + a9ffe6e commit 8a1187a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions library/src/main/scala/g8.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package giter8

import java.io.{File, InputStream}
import java.util.regex.Matcher
import java.util.{Locale, Properties}

import org.apache.commons.io.FileUtils
Expand Down Expand Up @@ -197,18 +198,15 @@ object G8 {

def expandPath(relative: String, toPath: File, parameters: Map[String, String]): Option[File] =
try {
val fileSeparator = System.getProperty("file.separator")
val fileSeparator = File.separator
val fileParams = Map(parameters.toSeq map {
case (k, v) if k == "package" =>
(k, v.replaceAll("""\.""", fileSeparator match {
case "\\" => "\\\\"
case sep => sep
}))
(k, v.replaceAll("""\.""", Matcher.quoteReplacement(fileSeparator)))
case x => x
}: _*)

val ignored = relative
.split(fileSeparator)
.split(File.separatorChar)
.map(part => applyTemplate(formatize(part), fileParams))
.exists(_.isEmpty)

Expand Down

0 comments on commit 8a1187a

Please sign in to comment.