Skip to content

Commit

Permalink
fix(test): get the tests passing again (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrobots authored Dec 18, 2018
1 parent 304c9e3 commit 6d009b8
Show file tree
Hide file tree
Showing 7 changed files with 430 additions and 320 deletions.
60 changes: 42 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@types/argparse": "^1.0.33",
"@types/mock-fs": "^3.6.30",
"@types/make-dir": "^1.0.3",
"@types/nock": "^9.1.3",
"@types/node": "^10.0.1",
"@types/npm-package-arg": "^6.0.0",
Expand All @@ -66,13 +66,16 @@
"@types/spdx-correct": "^2.0.0",
"@types/spdx-satisfies": "^0.1.0",
"@types/strip-json-comments": "0.0.30",
"@types/tmp": "0.0.33",
"ava": "^1.0.0",
"codecov": "^3.0.1",
"gts": "^0.9.0",
"make-dir": "^1.3.0",
"mock-fs": "^4.4.2",
"nock": "^10.0.0",
"nyc": "^13.0.0",
"proxyquire": "^2.0.1",
"tmp": "0.0.33",
"typescript": "~3.2.0"
}
}
10 changes: 8 additions & 2 deletions ts/src/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export interface CheckError {
parentPackages: string[];
}

export interface DefaultHandlerOptions {
setExitCode?: boolean;
}

type EventType = 'non-green-license'|'package.json'|'end'|'error';

export class LicenseChecker extends EventEmitter {
Expand Down Expand Up @@ -352,7 +356,7 @@ export class LicenseChecker extends EventEmitter {
}

/** set default event handlers for CLI output. */
setDefaultHandlers(): void {
setDefaultHandlers(options: DefaultHandlerOptions = {}): void {
let nonGreenCount = 0;
let errorCount = 0;
this.on('non-green-license',
Expand Down Expand Up @@ -383,7 +387,9 @@ export class LicenseChecker extends EventEmitter {
})
.on('end', () => {
if (nonGreenCount > 0 || errorCount > 0) {
process.exitCode = 1;
if (options.setExitCode) {
process.exitCode = 1;
}
if (nonGreenCount > 0) {
console.log(`${nonGreenCount} non-green licenses found.`);
}
Expand Down
Loading

0 comments on commit 6d009b8

Please sign in to comment.