squattingmonk/nasher

Enhancement Request - Return a non-zero exit code when there is a failure

Closed this issue · 2 comments

I've been looking for a way to programmatically work out if the nasher process worked or not when trying to build a module. Right now checking the exit code of the last run does not tell that as it always seems to have been successful.

It would be really useful to set a non-zero exit code if something when wrong in the build process (e.g. script compile failure) so that I can automatically block any further actions I may want to perform if the nasher command I've just run did not complete successfully.

I don't know nim (something I should probably learn at some point), but having a quick look at the code I think this may be all that's needed:

 of "unpack", "convert", "compile", "pack", "install", "play", "test", "serve":
        withTargets(pkgFile, opts):
          if cmd == "unpack":
            unpack(opts, target)
          else:
            var updatedNss: seq[string]
            if convert(opts, target, updatedNss) and
               compile(opts, target, updatedNss) and
               pack(opts, target) and
               install(opts, target):
                 launch(opts, target)
            else:
              quit(1)

I've not raised a PR since I really have no idea if this is the right approach and I may well be misinterpreting the code.

It's a bit more complicated. Those functions return true if they ought to continue to the next command (e.g., compile will return false if the user only wanted to compile and not proceed to packing). Will work on this today, though.

Raised a PR with an implementation that seems good locally.

#111

Let me know if you see any issues that need fixing.