Skip to content

Commit

Permalink
fix for 2954 running script in root dir (#2988)
Browse files Browse the repository at this point in the history
* fix for 2954 running script in root dir

* added simplification suggested by @Gedochao
  • Loading branch information
philwalk authored Jul 1, 2024
1 parent bf52053 commit 7a23f2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions modules/build/src/main/scala/scala/build/input/Inputs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ final case class Inputs(
workspace / Constants.workspaceDirName / projectName / "jar"
def docJarWorkDir: os.Path =
workspace / Constants.workspaceDirName / projectName / "doc"

}

object Inputs {
Expand Down Expand Up @@ -152,7 +153,7 @@ object Inputs {
updatedElems,
defaultMainClassElemOpt,
workspace,
workspace.baseName,
baseName(workspace),
mayAppendHash = needsHash,
workspaceOrigin = Some(workspaceOrigin),
enableMarkdown = enableMarkdown,
Expand Down Expand Up @@ -384,7 +385,6 @@ object Inputs {
}
}.getOrElse((os.pwd, true, WorkspaceOrigin.Forced))
}

val (workspace, needsHash, workspaceOrigin0) = forcedWorkspace match {
case None => (inferredWorkspace, inferredNeedsHash, workspaceOrigin)
case Some(forcedWorkspace0) =>
Expand Down Expand Up @@ -466,7 +466,7 @@ object Inputs {
elements = Nil,
defaultMainClassElement = None,
workspace = workspace,
baseProjectName = workspace.baseName,
baseProjectName = baseName(workspace),
mayAppendHash = true,
workspaceOrigin = None,
enableMarkdown = enableMarkdown,
Expand All @@ -475,4 +475,7 @@ object Inputs {

def empty(projectName: String): Inputs =
Inputs(Nil, None, os.pwd, projectName, false, None, true, false)

def baseName(p: os.Path) = if (p == os.root) "" else p.baseName

}
2 changes: 1 addition & 1 deletion modules/cli/src/main/scala/scala/cli/ScalaCli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ object ScalaCli {
try main0(args)
catch {
case e: Throwable if !isCI && !printStackTraces =>
val workspace = CurrentParams.workspaceOpt.getOrElse(os.pwd)
val workspace = CurrentParams.workspaceOpt.filter(os.isDir).getOrElse(os.pwd)
val dir = workspace / Constants.workspaceDirName / "stacktraces"
os.makeDir.all(dir)
import java.time.Instant
Expand Down

0 comments on commit 7a23f2b

Please sign in to comment.