Skip to content

Commit

Permalink
[fixes #114] - Custom URL/File parsing skipped if file found on disk
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Jul 18, 2017
1 parent a1bf8f1 commit ef812c1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -178,7 +178,7 @@ var flatten = function(options) {
/*istanbul ignore else*/
if (fs.lstatSync(licenseFile).isFile()) {
var content;
if (!moduleInfo.licenses || moduleInfo.licenses.indexOf(UNKNOWN) > -1) {
if (!moduleInfo.licenses || moduleInfo.licenses.indexOf(UNKNOWN) > -1 || moduleInfo.licenses.indexOf('Custom:') === 0) {
//Only re-check the license if we didn't get it from elsewhere
content = fs.readFileSync(licenseFile, { encoding: 'utf8' });
moduleInfo.licenses = license(content);
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -60,6 +60,7 @@
"github-changes": "^1.0.4",
"istanbul": "^0.4.3",
"jenkins-mocha": "^2.6.0",
"locale": "^0.1.0",
"queue": "^1.0.0",
"request": "^2.34.0",
"rimraf": "^2.5.4"
Expand Down
13 changes: 13 additions & 0 deletions tests/test.js
Expand Up @@ -217,6 +217,19 @@ describe('main tests', function() {
});
});

describe('should treat license file over custom urls', function() {

it('should recognise a custom license at a url', function(done) {
checker.init({
start: path.join(__dirname, '../node_modules/locale')
}, function(err, output) {
var item = output[Object.keys(output)[0]];
assert.equal(item.licenses, 'MIT*');
done();
});
});
});

describe('should treat URLs as custom licenses', function() {
var output;
before(function(done) {
Expand Down

0 comments on commit ef812c1

Please sign in to comment.