diff --git a/src/__mocks__/module-with-licence/LICENCE b/src/__mocks__/module-with-licence/LICENCE new file mode 100644 index 0000000..0db0e28 --- /dev/null +++ b/src/__mocks__/module-with-licence/LICENCE @@ -0,0 +1 @@ +LICENCE TEXT \ No newline at end of file diff --git a/src/__mocks__/module-with-license/LICENSE b/src/__mocks__/module-with-license/LICENSE new file mode 100644 index 0000000..44e2684 --- /dev/null +++ b/src/__mocks__/module-with-license/LICENSE @@ -0,0 +1 @@ +LICENSE TEXT \ No newline at end of file diff --git a/src/licenseUtils.js b/src/licenseUtils.js index 722ee7c..0b82190 100644 --- a/src/licenseUtils.js +++ b/src/licenseUtils.js @@ -9,7 +9,7 @@ const isSatisfiedLicense = require("spdx-satisfies"); const wrap = require("wrap-ansi"); const LicenseError = require("./LicenseError"); -const licenseGlob = "LICENSE*"; +const licenseGlob = "LICEN@(C|S)E*"; const licenseWrap = 80; const getLicenseContents = dependencyPath => { @@ -131,6 +131,7 @@ const writeLicenseInformation = (outputWriter, dependencies) => { module.exports = { getLicenseName, + getLicenseContents, getLicenseInformationForCompilation, getLicenseViolations, getSortedLicenseInformation, diff --git a/src/licenseUtils.spec.js b/src/licenseUtils.spec.js index a0dfb0c..92a761c 100644 --- a/src/licenseUtils.spec.js +++ b/src/licenseUtils.spec.js @@ -1,4 +1,4 @@ -const { getLicenseName } = require("./licenseUtils"); +const { getLicenseName, getLicenseContents } = require("./licenseUtils"); describe("getLicenseName", () => { let pkg; @@ -61,3 +61,30 @@ describe("getLicenseName", () => { }); }); }); + +describe("getLicenseContents", () => { + let licenseContent; + let depPath; + + describe("with licen(s)e file", () => { + beforeEach(() => { + depPath = process.cwd() + "/src/__mocks__/module-with-license/"; + licenseContent = getLicenseContents(depPath); + }); + + it("should return text content", () => { + expect(licenseContent).not.toBe(undefined); + }); + }); + + describe("with licen(c)e file", () => { + beforeEach(() => { + depPath = process.cwd() + "/src/__mocks__/module-with-licence/"; + licenseContent = getLicenseContents(depPath); + }); + + it("should return text content", () => { + expect(licenseContent).not.toBe(undefined); + }); + }); +});