Skip to content

Commit

Permalink
Remove null usage from scalamd/Main (scalatron#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcranky committed Dec 22, 2016
1 parent f81b3a4 commit 1e3c01d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -25,8 +25,8 @@ Scalatron is licensed under the Creative Commons Attribution 3.0 Unported Licens

## Build a new docker image

sbt docker
```sbt docker```

## Run inside a docker container

docker run -d -p 8080:8080 -v /tmp/bots:/opt/Scalatron/bots scalatron/scalatron:latest
```docker run -d -p 8080:8080 -v /tmp/bots:/opt/Scalatron/bots --name scalatron scalatron/scalatron:latest```
46 changes: 22 additions & 24 deletions ScalaMarkdown/src/org/fusesource/scalamd/Main.scala
Expand Up @@ -113,30 +113,28 @@ object Main {
outputBaseDirectoryPath: String,
verbose: Boolean): Unit = {
val inputDirectory = new File(inputDirectoryPath)
if (inputDirectory.getName.startsWith("_")) {
// skip
} else {
val fileList = inputDirectory.listFiles()
if (fileList == null || fileList.isEmpty) {
System.err.println(
"warning: no files to process in: " + inputDirectoryPath)
} else {
val (directoryCollection, fileCollection) =
fileList.partition(_.isDirectory)
directoryCollection.foreach(
dir =>
processDirectory(dir.getAbsolutePath,
outputDirectoryPath + "/" + dir.getName,
inputBaseDirectoryPath,
outputBaseDirectoryPath,
verbose))
fileCollection.foreach(
file =>
processFile(file.getAbsolutePath,
outputDirectoryPath,
inputBaseDirectoryPath,
outputBaseDirectoryPath,
verbose))

if (!inputDirectory.getName.startsWith("_")) {
val filesOpt = Option(inputDirectory.listFiles()).filter(_.nonEmpty)
if (filesOpt.isEmpty)
System.err.println("warning: no files to process in: " + inputDirectoryPath)

filesOpt.foreach { fileList =>
val (directoryCollection, fileCollection) = fileList.partition(_.isDirectory)
directoryCollection.foreach { dir =>
processDirectory(dir.getAbsolutePath,
outputDirectoryPath + "/" + dir.getName,
inputBaseDirectoryPath,
outputBaseDirectoryPath,
verbose)
}
fileCollection.foreach { file =>
processFile(file.getAbsolutePath,
outputDirectoryPath,
inputBaseDirectoryPath,
outputBaseDirectoryPath,
verbose)
}
}
}
}
Expand Down

0 comments on commit 1e3c01d

Please sign in to comment.