jakejarvis / hugo-extended

✏️ Plug-and-play Node.js wrapper for Hugo Extended, the awesomest static-site generator.
https://www.npmjs.com/package/hugo-extended
MIT License
25 stars 6 forks source link

Hugo exit status code isn't propagated for v0.84.0 or later #77

Closed chalin closed 3 years ago

chalin commented 3 years ago

When our website contains an error and hugo reports the error as expected, hugo's 255 exit status code isn't being propagated:

$ npx hugo; echo $? 
Start building sites … 
hugo v0.84.0-2C4689F7B+extended darwin/amd64 BuildDate=2021-06-18T17:14:27Z VendorInfo=gohugoio
Total in 131 ms
Error: Error building site: "/Users/chalin/git/lf/open-telemetry/opentelemetry.io/content/en/registry/instrumentation-go-xsam-database-sql.md:13:1": failed to unmarshal YAML: yaml: line 12: did not find expected key
0

Notice the 0 exit code being reported.

This wasn't the case for v0.83.x or earlier:

$ npx hugo version                    
hugo v0.83.0-4C65CECC+extended darwin/amd64 BuildDate=2021-05-01T12:10:08Z VendorInfo=gohugoio
$ npx hugo; echo $?
Start building sites … 
Total in 137 ms
Error: Error building site: "/Users/chalin/git/lf/open-telemetry/opentelemetry.io/content/en/registry/instrumentation-go-xsam-database-sql.md:13:1": failed to unmarshal YAML: yaml: line 12: did not find expected key
255

Notice the proper 255 exit code is being propagated.

This issue caused a build failure to go unnoticed, and a broken website to be deployed to our production server 😞. For details see, https://github.com/open-telemetry/opentelemetry.io/issues/823.

Thanks for the hugo-extended package @jakejarvis, it's super convenient. I hope that this issue can be easily and quickly resolved.

/cc @austinlparker @nate-double-u @celestehorgan

jakejarvis commented 3 years ago

Nice catch, sorry about this! I believe I've fixed it, pushing out v0.88.1-patch1 right now (kind of an ugly version but I still think matching this package's version with Hugo's is convenient). This also includes some refactoring I've done in the meantime so definitely let me know if you see any other issues!

jakejarvis commented 3 years ago

Also let me know if you need a Hugo version other than v0.88.1 patched.

chalin commented 3 years ago

Thanks for the quick fix @jakejarvis!

... pushing out v0.88.1-patch1 right now (kind of an ugly version but I still think matching this package's version with Hugo's is convenient).

I totally agree: I prefer that the package versions match. As I mentioned in https://github.com/fenneclab/hugo-bin/issues/105#issuecomment-942572355, you can use +1, +2, etc for hugo-extended patches. I believe that semver rules (relative to npm's ^ notation) will then allow those patched versions to be picked up automatically.

~Edit: maybe -patch1 works just as well.~

chalin commented 3 years ago

FYI, X.Y.Z-patch1 makes it a prerelease version of X.Y.Z, which isn't really what we want. IMHO, it would be better to use a + suffix (which is used for build metadata) instead. For details, see https://semver.org/#spec-item-10. Cheers