Skip to content

Commit

Permalink
Merge pull request #1901 from tgodzik/fix-scripts
Browse files Browse the repository at this point in the history
improvement: Support script files
  • Loading branch information
tgodzik authored Dec 13, 2023
2 parents f975afd + e6b6772 commit 3c9c5c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ case class Args(

object Args extends TPrintImplicits {
val baseMatcher: PathMatcher =
FileSystems.getDefault.getPathMatcher("glob:**.{scala,sbt}")
FileSystems.getDefault.getPathMatcher("glob:**.{scala,sbt,sc}")
val runtimeScalaVersion: ScalaVersion = ScalaVersion
.from(scala.util.Properties.versionNumberString) // can be empty
.toOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ case class ScalafixConfig(

def dialectForFile(path: String): Dialect =
if (path.endsWith(".sbt")) DefaultSbtDialect
else if (path.endsWith(".sc"))
dialect
.withAllowToplevelTerms(true)
else dialect

val reader: ConfDecoder[ScalafixConfig] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,24 @@ class CliSyntacticSuite extends BaseCliSuite {
expectedExit = ExitStatus.Ok
)

check(
name = "fix script files",
originalLayout = s"""|/a.sc
|def foo { println(1) }
|lazy val bar = project
|""".stripMargin,
args = Array(
"-r",
"ProcedureSyntax",
"a.sc"
),
expectedLayout = s"""|/a.sc
|def foo: Unit = { println(1) }
|lazy val bar = project
|""".stripMargin,
expectedExit = ExitStatus.Ok
)

check(
name = "deprecated name emits warning",
originalLayout = s"""|/a.scala
Expand Down

0 comments on commit 3c9c5c5

Please sign in to comment.