gma / nesta

File Based CMS and Static Site Generator
http://nestacms.com
MIT License
902 stars 120 forks source link

Prevent Nesta system calls from failing silently. Fixes gma/nesta#128. #154

Closed jkowens closed 9 years ago

jkowens commented 9 years ago

Adds a run method to the Command module that wraps system calls. A RuntimeError is raised if the system call fails.

gma commented 9 years ago

Hey. I'm sorry I didn't get to your question about how to deal with this before you worked up a patch for it.

I'd been discussing how to fix this with James Abbott earlier this year, and when I saw your question I wondered why there wasn't a pull request for it. It turns out he put a patch on his fork but never sent me a pull request, most likely because his tests would have been failing.

I'd have merged this, but James and I had got as far as deciding we should print an error message rather than a stack trace. If it's any consolation, your $?.exitstatus code was very handy, as my initial approach (checking the return value of system) doesn't work as it says it should in the Ruby docs (it returns nil far more often than it ought to).

And if you hadn't sent a PR, I'd never have dug into what happened to James's patch, so in effect you've still fixed it…

jkowens commented 9 years ago

No worries, I was just looking for a small challenge. I'm glad I was able to help in some way :)