Skip to content

Commit

Permalink
Update licenseGlob to allow checking for LICENCE files (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickysullivan-gallagher authored Dec 16, 2020
1 parent f376e54 commit affc098
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/__mocks__/module-with-licence/LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LICENCE TEXT
1 change: 1 addition & 0 deletions src/__mocks__/module-with-license/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LICENSE TEXT
3 changes: 2 additions & 1 deletion src/licenseUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -131,6 +131,7 @@ const writeLicenseInformation = (outputWriter, dependencies) => {

module.exports = {
getLicenseName,
getLicenseContents,
getLicenseInformationForCompilation,
getLicenseViolations,
getSortedLicenseInformation,
Expand Down
29 changes: 28 additions & 1 deletion src/licenseUtils.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getLicenseName } = require("./licenseUtils");
const { getLicenseName, getLicenseContents } = require("./licenseUtils");

describe("getLicenseName", () => {
let pkg;
Expand Down Expand Up @@ -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);
});
});
});

0 comments on commit affc098

Please sign in to comment.