Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit c4057d6

Browse files
committed
Fix description in create task not showing up on windows and add some missing tailrec annotations.
1 parent edb1b0d commit c4057d6

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

build/src/main/scala/org/codeoverflow/chatoverflow/build/BuildUtils.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,11 @@ object BuildUtils {
3535
val dirEntries = dir.listFiles()
3636
(dirEntries.filter(_.isFile) ++ dirEntries.filter(_.isDirectory).flatMap(getAllDirectoryChilds)).toSet
3737
}
38+
39+
/**
40+
* Checks whether the current os is windows.
41+
*
42+
* @return true if running on any windows version, false otherwise
43+
*/
44+
def isRunningOnWindows: Boolean = System.getProperty("os.name").toLowerCase().contains("win")
3845
}

build/src/main/scala/org/codeoverflow/chatoverflow/build/GUIUtility.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class GUIUtility(logger: ManagedLogger) {
8181
}
8282

8383
private def getNpmCommand: List[String] = {
84-
if (System.getProperty("os.name").toLowerCase().contains("win")) {
84+
if (BuildUtils.isRunningOnWindows) {
8585
List("cmd.exe", "/C", "npm")
8686
} else {
8787
List("npm")

build/src/main/scala/org/codeoverflow/chatoverflow/build/plugins/Plugin.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import java.io.File
55
import org.codeoverflow.chatoverflow.build.SbtFile
66
import sbt.io.IO
77

8+
import scala.annotation.tailrec
89
import scala.util.Try
910
import scala.xml.PrettyPrinter
1011

@@ -154,6 +155,7 @@ object Plugin {
154155
pluginSourceFolder.exists() && pluginSourceFolder.isDirectory
155156
}
156157

158+
@tailrec
157159
private def toNormalizedName(name: String): String = {
158160
if (name.isEmpty) {
159161
return ""

build/src/main/scala/org/codeoverflow/chatoverflow/build/plugins/PluginCreateWizard.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package org.codeoverflow.chatoverflow.build.plugins
22

33
import java.io.File
44

5+
import org.codeoverflow.chatoverflow.build.BuildUtils
56
import org.codeoverflow.chatoverflow.build.BuildUtils.withTaskInfo
67
import org.codeoverflow.chatoverflow.build.plugins.PluginCreateWizard.askForInput
78
import sbt.internal.util.ManagedLogger
89

10+
import scala.annotation.tailrec
11+
912
class PluginCreateWizard(logger: ManagedLogger) {
1013

1114
/**
@@ -128,10 +131,11 @@ object PluginCreateWizard {
128131

129132
def apply(logger: ManagedLogger): PluginCreateWizard = new PluginCreateWizard(logger)
130133

134+
@tailrec
131135
private def askForInput(information: String, description: String, validate: String => Boolean = _ => true,
132136
validationDescription: String = ""): String = {
133137
println(information)
134-
print(s"$description > ")
138+
print(s"$description > ${if (BuildUtils.isRunningOnWindows) "\n" else ""}")
135139

136140
val input = scala.io.Source.fromInputStream(System.in).bufferedReader().readLine()
137141
println("")

0 commit comments

Comments
 (0)