Skip to content

Commit

Permalink
feat: Return a non-zero exit code on compile failure (#111)
Browse files Browse the repository at this point in the history
Closes #109.
  • Loading branch information
Ardesco authored Aug 15, 2023
1 parent 4065ab4 commit ba54ed3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/nasher.nim
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ when isMainModule:
unpack(opts, target)
else:
var updatedNss: seq[string]
var exitCode = QuitSuccess
if convert(opts, target, updatedNss) and
compile(opts, target, updatedNss) and
compile(opts, target, updatedNss, exitCode) and
pack(opts, target) and
install(opts, target):
launch(opts, target)
if exitCode != QuitSuccess:
quit(exitCode)
else:
help(helpAll, QuitFailure)
except SyntaxError, PackageError:
Expand Down
6 changes: 5 additions & 1 deletion src/nasher/compile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ proc getUpdated(updatedNSS: var seq[string], files: seq[string]): seq[string] =

updatedNss = result

proc compile*(opts: Options, target: Target, updatedNss: var seq[string]): bool =
proc compile*(opts: Options, target: Target, updatedNss: var seq[string], exitCode: var int): bool =
let
cmd = opts["command"]
cacheDir = ".nasher" / "cache" / target.name
Expand Down Expand Up @@ -196,6 +196,7 @@ proc compile*(opts: Options, target: Target, updatedNss: var seq[string]): bool
hint("This was chunk $1 out of $2" % [$(chunk + 1), $chunks])
if not askIf("Do you want to continue compiling?"):
setForceAnswer(forced)
exitCode = QuitFailure
return false
else:
display("Skipping", "compilation: nothing to compile")
Expand All @@ -212,7 +213,10 @@ proc compile*(opts: Options, target: Target, updatedNss: var seq[string]): bool
setForceAnswer(abortOnCompileError)
if not askIf("Do you want to continue to $#?" % [cmd]):
setForceAnswer(forced)
exitCode = QuitFailure
return false
else:
exitCode = QuitFailure
else:
success("All executable scripts have a matching compiled (.ncs) script", LowPriority);
if scripts.len > 0:
Expand Down

0 comments on commit ba54ed3

Please sign in to comment.