j-d-carmichael / boats

Beautiful Open Api Template System
MIT License
57 stars 8 forks source link

boats does not exit properly #12

Closed p-mcgowan closed 4 years ago

p-mcgowan commented 4 years ago

npm run build:json && npm run build:yaml will always run build:yaml, because the json process never exits with code > 0

so if you have a script that runs npm run build:json && cp output to other place, this will erroneously copy the file every time

in cli.js:

}).catch(error => {
  console.trace(error)
  process.exit(1) // <- this is required
})
p-mcgowan commented 4 years ago

if eslint insists that process.exit is bad, then the error could either be traced and re-thrown, or just left uncaught.

I could see it being the case if the source was imported and used programatically, but the cli should catch it's own errors, and exit - AFAIK i don't see a use for importing the cli into another node script

additionally, bundleSwaggerParse catches it's own error and does not propagate it - resulting in logging the error and the process continuing on:

// bundlerSwaggerParse.js:47 bundler json stringify bundled
undefined  
// bundlerSwaggerParse.js:48 bundler log error
{
  stack: 'ResolverError: Error opening file "something.yml" \n' +
    "ENOENT: blah blah stacktrace",
  source: 'something.yml',
  path: [],
  toJSON: [Function: toJSON],
  ioErrorCode: 'ENOENT',
  name: 'ResolverError',
  toString: [Function: toString]
}
// cli.js:59 error was caught, logged, not re-thrown, so the cli continues on and tries to colourize and report success
Trace: TypeError: Cannot read property 'green' of undefined
    at swagger/node_modules/boats/src/cli.js:59:104
    at swagger/node_modules/boats/src/cli.js:62:11