Skip to content

Commit

Permalink
allow reporting of absolute license file path
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Sobolewski committed Jan 18, 2018
1 parent 8d960c6 commit 32455c4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,17 @@ var flatten = function(options) {
});

files.forEach(function(filename) {
console.log('json.path', json.path)
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()) {
if (options.global.relativeLicensePath) {
// Asking for absolute path overrides asking for relative
if (options.global.relativeLicensePath && !options.global.absoluteLicensePath) {
moduleInfo.licenseFile = path.relative(options.global.start, licenseFile)
}
if (options.global.absoluteLicensePath) {
moduleInfo.licenseFile = path.normalize(licenseFile);
}
if (! moduleInfo.licenses) {
var tempLicense = license(fs.readFileSync(licenseFile, {encoding: 'utf8'}));
if (tempLicense !== null) {
Expand Down Expand Up @@ -185,7 +190,7 @@ exports.print = function(sorted) {
exports.asCSV = function(sorted, options) {
options = options = options || {};
var format;
if (options.relativeLicensePath) {
if (options.relativeLicensePath || options.absoluteLicensePath) {
format = ["module name", "licenses", "repository", "licenseUrl", "licenseFile", "parents"]
}
else {
Expand Down

0 comments on commit 32455c4

Please sign in to comment.