Skip to content

Commit

Permalink
Added checking that the license file is a normal file, because otherw…
Browse files Browse the repository at this point in the history
…ise an appropriately named directory crashes the license-checker through EISDIR, illegal operation on a directory.
  • Loading branch information
Tero Keski-Valkama committed Aug 12, 2014
1 parent c14ef79 commit e39ad9b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var license = require('./license');

var flatten = function(json) {
var moduleInfo = {licenses: UNKNOWN},
licenseData, files;
licenseData, files, licenseFile;

data[json.name + '@' + json.version] = moduleInfo;

Expand Down Expand Up @@ -55,7 +55,11 @@ var flatten = function(json) {
});

files.forEach(function(filename) {
moduleInfo.licenses = license(fs.readFileSync(path.join(json.path, filename), {encoding: 'utf8'}));
licenseFile = path.join(json.path, filename);
// Checking that the file is in fact a normal file and not a directory for example.
if (fs.lstatSync(licenseFile).isFile()) {
moduleInfo.licenses = license(fs.readFileSync(licenseFile, {encoding: 'utf8'}));
}
});
}

Expand Down

0 comments on commit e39ad9b

Please sign in to comment.