mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 18:11:48 +04:00
Add initial implementation for running SBT commands.
This commit is contained in:
parent
81db32e148
commit
163e418754
10 changed files with 185 additions and 1 deletions
6
testing/resources/sbt_hooks_repo/.pre-commit-hooks.yaml
Normal file
6
testing/resources/sbt_hooks_repo/.pre-commit-hooks.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
- id: sbt-create-files
|
||||
name: touch
|
||||
entry: touch
|
||||
args: ["file1.txt", "\"file2 with space.txt\""]
|
||||
description: "creates files provided by `args` or `files`"
|
||||
language: sbt
|
||||
6
testing/resources/sbt_repo_with_touch_command/build.sbt
Normal file
6
testing/resources/sbt_repo_with_touch_command/build.sbt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import TouchCommand._
|
||||
|
||||
lazy val root = (project in file("."))
|
||||
.settings(
|
||||
commands ++= Seq(touchCommand)
|
||||
)
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import sbt.Command
|
||||
|
||||
import java.nio.file.{Files, Paths}
|
||||
|
||||
object TouchCommand {
|
||||
def touchCommand = Command.args("touch", "args") { (state, args) =>
|
||||
args.map(Paths.get(_).toAbsolutePath).foreach { path =>
|
||||
println(f"Creating file: $path")
|
||||
Files.createFile(path)
|
||||
}
|
||||
state
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue