Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add projectsGraphPng #30

Merged
merged 1 commit into from
Jun 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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