Skip to content

Commit

Permalink
Fixed hanging process on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jeemok committed Dec 1, 2021
1 parent f5ebe1f commit 697421d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/handlers/handleFinish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ export default function handleFinish(jsonBuffer: string, auditLevel: AuditLevel,
} else {
// Happy happy, joy joy
console.info('🤝 All good!');
process.exit(0);
}
}
12 changes: 12 additions & 0 deletions test/handlers/handleFinish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,42 @@ describe('Events handling', () => {
});

it('should be able to handle success case properly', () => {
const processStub = sinon.stub(process, 'exit');
const consoleStub = sinon.stub(console, 'info');
const jsonBuffer = JSON.stringify(V6_JSON_BUFFER_EMPTY);
const auditLevel = 'info';
const exceptionIds: number[] = [];

expect(consoleStub.called).to.equal(false);
handleFinish(jsonBuffer, auditLevel, exceptionIds);

expect(processStub.called).to.equal(true);
expect(processStub.calledWith(0)).to.equal(true);

expect(consoleStub.called).to.equal(true);
expect(consoleStub.calledWith('🤝 All good!')).to.equal(true);

processStub.restore();
consoleStub.restore();
});

it('should be able to except vulnerabilities properly', () => {
const processStub = sinon.stub(process, 'exit');
const consoleStub = sinon.stub(console, 'info');
const jsonBuffer = JSON.stringify(V6_JSON_BUFFER);
const auditLevel = 'info';
const exceptionIds = [975, 976, 985, 1084, 1179, 1213, 1500, 1523, 1555, 1556, 1589];

expect(consoleStub.called).to.equal(false);
handleFinish(jsonBuffer, auditLevel, exceptionIds);

expect(processStub.called).to.equal(true);
expect(processStub.calledWith(0)).to.equal(true);

expect(consoleStub.called).to.equal(true);
expect(consoleStub.calledWith('🤝 All good!')).to.equal(true);

processStub.restore();
consoleStub.restore();
});

Expand Down

0 comments on commit 697421d

Please sign in to comment.