Skip to content

Commit

Permalink
Merge pull request #30 from dwijnand/add-projectsGraphPng
Browse files Browse the repository at this point in the history
Add projectsGraphPng
  • Loading branch information
dwijnand authored Jun 4, 2018
2 parents f1cb409 + 9f4812b commit 5ebd21c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/scala/sbtprojectgraph/SbtProjectGraphPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ object SbtProjectGraphPlugin extends AutoPlugin {
override def buildSettings: Seq[Setting[_]] = Seq(
commands ++= Seq(
projectsGraphDot,
projectsGraphSvg
projectsGraphSvg,
projectsGraphPng
)
)

Expand All @@ -18,13 +19,16 @@ object SbtProjectGraphPlugin extends AutoPlugin {
state
}

val projectsGraphSvg = Command.command("projectsGraphSvg") { s =>
val projectsGraphSvg = Command.command("projectsGraphSvg")(dotTo("svg"))
val projectsGraphPng = Command.command("projectsGraphPng")(dotTo("png"))

private[this] def dotTo(outputFormat: String)(s: State) = {
val (dotFile, state) = executeProjectsGraphDot(s)
val extracted = Project extract state
val svgFile = extracted.get(target) / "projects-graph.svg"
val command = Seq("dot", "-o" + svgFile.getAbsolutePath, "-Tsvg", dotFile.getAbsolutePath)
val outFile = extracted.get(target) / s"projects-graph.$outputFormat"
val command = Seq("dot", "-o" + outFile.getAbsolutePath, s"-T$outputFormat", dotFile.getAbsolutePath)
sys.process.Process(command).!
extracted get sLog info s"Wrote project graph to '$svgFile'"
extracted get sLog info s"Wrote project graph to '$outFile'"
state
}

Expand Down

2 comments on commit 5ebd21c

@jaceklaskowski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.4.0 release?

@dwijnand
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well alright then 😉

Please sign in to comment.