From 0470a3fb774fd42e54be8eaaf3b379e2f69d1108 Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Wed, 10 Jan 2018 16:59:35 -0800 Subject: [PATCH] chore: allow LicenseChecker to be created with no args --- ts/src/checker.ts | 2 +- ts/test/checker-test.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ts/src/checker.ts b/ts/src/checker.ts index 0a1bc07..30f963b 100644 --- a/ts/src/checker.ts +++ b/ts/src/checker.ts @@ -86,7 +86,7 @@ export class LicenseChecker extends EventEmitter { // List of license names that are not SPDX-conforming IDs but are allowed. private whitelistedLicenses: string[] = []; - constructor({dev = false, verbose = false}: LicenseCheckerOptions) { + constructor({dev = false, verbose = false}: LicenseCheckerOptions = {}) { super(); this.opts = {dev, verbose}; } diff --git a/ts/test/checker-test.ts b/ts/test/checker-test.ts index b0dbf57..45dcbd2 100644 --- a/ts/test/checker-test.ts +++ b/ts/test/checker-test.ts @@ -64,7 +64,7 @@ test.serial( async t => { requestedPackages = []; const nonGreenPackages: string[] = []; - const checker = new LicenseChecker({}); + const checker = new LicenseChecker(); checker.on('non-green-license', arg => { nonGreenPackages.push(`${arg.packageName}@${arg.version}`); }); @@ -91,7 +91,7 @@ test.serial('local directory is checked correctly', async t => { try { requestedPackages = []; const nonGreenPackages: string[] = []; - const checker = new LicenseChecker({}); + const checker = new LicenseChecker(); checker.on('non-green-license', arg => { nonGreenPackages.push(`${arg.packageName}@${arg.version}`); }); @@ -121,7 +121,7 @@ test.serial('local directory should have correct licenses too', async t => { try { requestedPackages = []; const nonGreenPackages: string[] = []; - const checker = new LicenseChecker({}); + const checker = new LicenseChecker(); checker.on('non-green-license', arg => { nonGreenPackages.push(`${arg.packageName}@${arg.version}`); }); @@ -165,7 +165,7 @@ test.serial('local monorepo directory is checked correctly', async t => { requestedPackages = []; const nonGreenPackages: string[] = []; const packageJsonPaths: string[] = []; - const checker = new LicenseChecker({}); + const checker = new LicenseChecker(); checker .on('non-green-license', (arg) => { @@ -209,7 +209,7 @@ test.serial('package whitelist should be respected (local repo)', async t => { try { requestedPackages = []; const nonGreenPackages: string[] = []; - const checker = new LicenseChecker({}); + const checker = new LicenseChecker(); checker.on('non-green-license', arg => { nonGreenPackages.push(`${arg.packageName}@${arg.version}`); }); @@ -245,7 +245,7 @@ test.serial('custom green license list (local repo)', async t => { try { requestedPackages = []; const nonGreenPackages: string[] = []; - const checker = new LicenseChecker({}); + const checker = new LicenseChecker(); checker.on('non-green-license', arg => { nonGreenPackages.push(`${arg.packageName}@${arg.version}`); }); @@ -270,7 +270,7 @@ test.serial('errors properly output to console', async t => { }; requestedPackages = []; const nonGreenPackages: string[] = []; - const checker = new LicenseChecker({}); + const checker = new LicenseChecker(); checker.setDefaultHandlers(); await checker.checkRemotePackage('foo'); console.log = realConsoleLog;