Skip to content

Commit 2f98c53

Browse files
Allow users to specify whether the launcher is compressed or not
1 parent 69f66df commit 2f98c53

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

src/ScalaCliCompile.scala

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,31 @@ trait ScalaCliCompile extends ScalaModule {
3434
new FallbackRefreshDisplay
3535
)
3636
val cache = FileCache().withLogger(logger)
37+
val artifact = Artifact(url).withChanging(compileScalaCliIsChanging)
3738
val archiveCache = ArchiveCache()
3839
.withCache(cache)
39-
val artifact = Artifact(url).withChanging(compileScalaCliIsChanging)
40-
val file = archiveCache.get(artifact).unsafeRun()(cache.ec) match {
41-
case Left(e) => throw new Exception(e)
42-
case Right(f) =>
43-
if (Properties.isWin)
44-
os.list(os.Path(f, os.pwd)).filter(_.last.endsWith(".exe")).headOption match {
45-
case None => sys.error(s"No .exe found under $f")
46-
case Some(exe) => exe
40+
if (compileScalaCliIsCompressed)
41+
archiveCache.get(artifact).unsafeRun()(cache.ec) match {
42+
case Left(e) => throw new Exception(e)
43+
case Right(f) =>
44+
if (Properties.isWin)
45+
os.list(os.Path(f, os.pwd)).filter(_.last.endsWith(".exe")).headOption match {
46+
case None => sys.error(s"No .exe found under $f")
47+
case Some(exe) => exe
48+
}
49+
else {
50+
f.setExecutable(true)
51+
os.Path(f, os.pwd)
4752
}
48-
else {
49-
f.setExecutable(true)
53+
}
54+
else
55+
cache.file(artifact).run.unsafeRun()(cache.ec) match {
56+
case Left(e) => throw new Exception(e)
57+
case Right(f) =>
58+
if (!Properties.isWin)
59+
f.setExecutable(true)
5060
os.Path(f, os.pwd)
51-
}
52-
}
53-
PathRef(file)
61+
}
5462
}
5563
}
5664
import ScalaCliInternal._
@@ -74,8 +82,10 @@ trait ScalaCliCompile extends ScalaModule {
7482
else None
7583
}
7684
def compileScalaCliIsChanging: Boolean = false
85+
def compileScalaCliIsCompressed: Boolean =
86+
compileScalaCliUrl.exists(url => url.endsWith(".gz") || url.endsWith(".zip"))
7787

78-
def compileScalaCli: Option[PathRef] = compileScalaCliImpl
88+
def compileScalaCli: Option[os.Path] = compileScalaCliImpl
7989

8090
def extraScalaCliOptions: T[List[String]] =
8191
T {
@@ -84,7 +94,7 @@ trait ScalaCliCompile extends ScalaModule {
8494

8595
override def compile: T[CompilationResult] =
8696
if (enableScalaCli)
87-
compileScalaCli.map(_.path) match {
97+
compileScalaCli match {
8898
case None => super.compile
8999
case Some(cli) =>
90100
T.persistent {

0 commit comments

Comments
 (0)