Skip to content

Commit

Permalink
fix: exit with 1 for failing validations (#1068)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarnoRFB authored Jan 29, 2024
1 parent 276b5cc commit 3f4ee3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/commands/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
3 changes: 2 additions & 1 deletion test/integration/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('validate', () => {
testHelper.setCurrentContext('home');
testHelper.deleteDummyContextFile();
});

test
.stderr()
.stdout()
Expand Down Expand Up @@ -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();
});
});
Expand Down

0 comments on commit 3f4ee3e

Please sign in to comment.