Skip to content

Commit

Permalink
[fixes #78] - include notice file if found
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Sep 9, 2016
1 parent dfcbd6f commit b5f5c6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 16 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var flatten = function(options) {
colorize = options.color,
unknown = options.unknown,
readmeFile,
licenseData, files = [], licenseFile;
licenseData, dirFiles, files = [], noticeFiles = [], licenseFile;

/*istanbul ignore next*/
if (colorize) {
Expand Down Expand Up @@ -135,11 +135,17 @@ var flatten = function(options) {

/*istanbul ignore else*/
if (json.path && fs.existsSync(json.path)) {
files = fs.readdirSync(json.path).filter(function(filename) {
dirFiles = fs.readdirSync(json.path);
files = dirFiles.filter(function(filename) {
filename = filename.toUpperCase();
var name = path.basename(filename).replace(path.extname(filename), '');
return name === 'LICENSE' || name === 'LICENCE';
});
noticeFiles = dirFiles.filter(function(filename) {
filename = filename.toUpperCase();
var name = path.basename(filename).replace(path.extname(filename), '');
return name === 'NOTICE';
});
}

files.forEach(function(filename) {
Expand All @@ -155,6 +161,14 @@ var flatten = function(options) {
}
});

noticeFiles.forEach(function(filename) {
var file = path.join(json.path, filename);
/*istanbul ignore else*/
if (fs.lstatSync(file).isFile()) {
moduleInfo.noticeFile = options.basePath ? path.relative(options.basePath, file) : file;
}
});

/*istanbul ignore else*/
if (json.dependencies) {
Object.keys(json.dependencies).forEach(function(name) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
"treeify": "^1.0.1"
},
"devDependencies": {
"camden.jshint": "cfjedimaster/brackets-jshint",
"detectionizr": "*",
"format-package-json": "^0.2.0",
"github-changes": "^1.0.4",
"git-contributors": "^0.2.3",
"github-changes": "^1.0.4",
"istanbul": "^0.4.3",
"jenkins-mocha": "^2.6.0",
"jshint": "~1.1.0",
Expand Down

0 comments on commit b5f5c6a

Please sign in to comment.