diff --git a/src/commands/validate.ts b/src/commands/validate.ts index 7254b52f4f5..24cd74ac061 100644 --- a/src/commands/validate.ts +++ b/src/commands/validate.ts @@ -23,12 +23,16 @@ export default class Validate extends Command { const { args, flags } = await this.parse(Validate); //NOSONAR const filePath = args['spec-file']; const watchMode = flags.watch; - + const specFile = await load(filePath); if (watchMode) { specWatcher({ spec: specFile, handler: this, handlerName: 'validate' }); } await validate(this, specFile, flags); + if(await validate(this, specFile, flags) == 'invalid') { + this.exit(1); + } + this.exit(0); } } diff --git a/src/parser.ts b/src/parser.ts index 8e35adc56f6..72a89bbf9f2 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -74,7 +74,7 @@ function logDiagnostics(diagnostics: Diagnostic[], command: Command, specFile: S const logDiagnostics = options['log-diagnostics']; const failSeverity = options['fail-severity'] ?? 'error'; const diagnosticsFormat = options['diagnostics-format'] ?? 'stylish'; - + const sourceString = specFile.toSourceString(); if (diagnostics.length) { if (hasFailSeverity(diagnostics, failSeverity)) {