ga4gh / gh-openapi-docs

Package for building OpenAPI schema docs and UI for gh-pages
Apache License 2.0
7 stars 5 forks source link

Abort program if a subprocess fails #60

Open jb-adams opened 3 years ago

jb-adams commented 3 years ago

@tschaffter @jaeddy

Currently, it doesn't seem that the program exits early if a subprocess (executed through shell.exec) fails. For example, I sometimes get the following error from the npx redoc-cli bundle --output ${indexPath} ${OPENAPI_YAML_PATH} ${redocOpts} command:

TypeError: Object(...) is not a function
    at new GroupModel (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:10182:49)
    at /usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:10292:29
    at Array.map (<anonymous>)
    at mapHeadingsDeep (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:10291:26)
    at Function.MenuBuilder.addMarkdownItems (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:10303:16)
    at Function.MenuBuilder.buildStructure (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:10270:45)
    at new SpecStore (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:10161:53)
    at new AppStore (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:12804:21)
    at Module.<anonymous> (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:12788:43)
    at step (/usr/local/lib/node_modules/redoc-cli/node_modules/tslib/tslib.js:140:27)

When running this command manually, I can see the exit code is 1.

Can we introduce a module that will run all the shell commands in sequence, and after each one, check the exit code? If 0, continue as normal, if not, throw an error. This will make it easier to see when the program has failed.

tschaffter commented 3 years ago

Related to #42