Skip to content

Commit

Permalink
refactor: Add a comment and increase type safety a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Seidelsohn committed May 12, 2023
1 parent cbbbba4 commit eb87e1b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,14 +953,15 @@ const getCsvData = (sorted, customFormat, csvComponentPrefix) => {
dataElements.push(`"${csvComponentPrefix}"`);
}

//Grab the custom keys from the custom format
if (customFormat && Object.keys(customFormat).length > 0) {
// Grab the custom keys from the custom format
if (typeof customFormat === 'object' && Object.keys(customFormat).length > 0) {
dataElements.push(`"${key}"`);

Object.keys(customFormat).forEach((item) => {
dataElements.push(`"${module[item]}"`);
});
} else {
// Be sure to push empty strings for empty values, as this is what CSV expects:
dataElements.push([`"${key}"`, `"${module.licenses || ''}"`, `"${module.repository || ''}"`]);
}

Expand Down

0 comments on commit eb87e1b

Please sign in to comment.