diff --git a/src/commands/validate.ts b/src/commands/validate.ts index 7254b52f4f5..c678b5f662c 100644 --- a/src/commands/validate.ts +++ b/src/commands/validate.ts @@ -29,6 +29,9 @@ export default class Validate extends Command { specWatcher({ spec: specFile, handler: this, handlerName: 'validate' }); } - await validate(this, specFile, flags); + const validationResult = await validate(this, specFile, flags); + if (validationResult === 'invalid') { + process.exitCode = 1; + } } } diff --git a/test/integration/validate.test.ts b/test/integration/validate.test.ts index c0298279bc9..d63921f4b6f 100644 --- a/test/integration/validate.test.ts +++ b/test/integration/validate.test.ts @@ -117,7 +117,7 @@ describe('validate', () => { testHelper.setCurrentContext('home'); testHelper.deleteDummyContextFile(); }); - + test .stderr() .stdout() @@ -241,6 +241,7 @@ describe('validate', () => { .command(['validate', './test/fixtures/specification.yml', '--fail-severity=warn']) .it('works with --fail-severity', (ctx, done) => { expect(ctx.stderr).to.include('\nFile ./test/fixtures/specification.yml and/or referenced documents have governance issues.\n\ntest/fixtures/specification.yml'); + expect(process.exitCode).to.equal(1); done(); }); });