Skip to content

Commit 0590d0f

Browse files
committed
Minor changes
1 parent 0b56853 commit 0590d0f

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

modules/cli/src/main/scala/scala/cli/commands/Compile.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object Compile extends ScalaCommand[CompileOptions] {
1919
Some(name)
2020
)
2121
if (CommandUtils.shouldCheckUpdate)
22-
Update.checkUpdate(logger)
22+
Update.checkUpdateSafe(logger)
2323

2424
val cross = options.cross.cross.getOrElse(false)
2525
if (options.classPath && cross) {

modules/cli/src/main/scala/scala/cli/commands/Run.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object Run extends ScalaCommand[RunOptions] {
4646
Some(name)
4747
)
4848
if (CommandUtils.shouldCheckUpdate)
49-
Update.checkUpdate(logger)
49+
Update.checkUpdateSafe(logger)
5050

5151
if (options.watch.watch) {
5252
val watcher = Build.watch(

modules/cli/src/main/scala/scala/cli/commands/Test.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object Test extends ScalaCommand[TestOptions] {
2626
Some(name)
2727
)
2828
if (CommandUtils.shouldCheckUpdate)
29-
Update.checkUpdate(logger)
29+
Update.checkUpdateSafe(logger)
3030

3131
val initialBuildOptions = options.buildOptions
3232
val bloopRifleConfig = options.shared.bloopRifleConfig()

modules/cli/src/main/scala/scala/cli/commands/Update.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ object Update extends ScalaCommand[UpdateOptions] {
2929
// format: off
3030
val res = os.proc(
3131
"sh", "-s", "--",
32+
"--version", newVersion,
3233
"--force",
3334
"--binary-name", options.binaryName,
3435
"--bin-dir", options.installDirPath,
35-
newVersion
3636
).call(
3737
cwd = os.pwd,
3838
stdin = installScript.stdout,
@@ -65,14 +65,15 @@ object Update extends ScalaCommand[UpdateOptions] {
6565
sys.error("Can not resolve ScalaCLI version to update")
6666
)
6767

68+
val isOutdated = CommandUtils.isOutOfDateVersion(newestScalaCliVersion, currentVersion)
69+
6870
if (!options.isInternalRun)
69-
if (CommandUtils.isOutOfDateVersion(newestScalaCliVersion, currentVersion))
71+
if (isOutdated)
7072
updateScalaCli(options, newestScalaCliVersion)
7173
else println("ScalaCLI is up-to-date")
72-
else
74+
else if (isOutdated)
7375
println(
74-
s"""Your ScalaCLI $currentVersion is outdated, please update ScalaCLI to $newestScalaCliVersion
75-
76+
s"""Your ScalaCLI $currentVersion is outdated, please update ScalaCLI to $newestScalaCliVersion
7677
|Run 'curl -sSLf https://virtuslab.github.io/scala-cli-packages/scala-setup.sh | sh' to update ScalaCLI.""".stripMargin
7778
)
7879
}
@@ -109,7 +110,7 @@ object Update extends ScalaCommand[UpdateOptions] {
109110
def run(options: UpdateOptions, args: RemainingArgs): Unit =
110111
checkUpdate(options)
111112

112-
def checkUpdate(logger: Logger): Unit = {
113+
def checkUpdateSafe(logger: Logger): Unit = {
113114
Try {
114115
val classesDir =
115116
this.getClass.getProtectionDomain.getCodeSource.getLocation.toURI.toString

0 commit comments

Comments
 (0)